2
input[type="checkbox"].focus {border:0px;}<br>
input[type="text"].focus {border:0px;}

How can I combine the two things into one?

$("input[type='text'],input[type='checkbox']").focus {border:0px;}
3
  • Yes, this is JQuery. Can't figure it out. If I wrote the code separately, it would work. A combined code above is not working.. Commented Sep 10, 2012 at 18:03
  • check my answer and let me know it i am lagging somewhere Commented Sep 10, 2012 at 18:04
  • 1
    Please edit the question and answer to include the updated code. The question isn't just for you, it's for everyone that ever comes across this problem. Commented Sep 10, 2012 at 20:46

2 Answers 2

1

You need to do this work like this you can not add CSS on the jQuery like we do in css to add css using jQuery you can use css() jQuery API the method is css (propertyName, value)

focus(function(){
    $(this).css("background-color","#FFFFCC");
}); 

For more information about the jQuery CSS check this link

Sign up to request clarification or add additional context in comments.

Comments

0
$("input[type='text'],input[type='checkbox']").focus() {border:0px;}
  1. You're missing the closing double-quote in your selector.
  2. focus returns the handler currently attached to the focus event. You want to actually invoke the method, so you need the empty argument list: focus()

2 Comments

Please edit the question and answer to include the updated code. The question isn't just for you, it's for everyone that ever comes across this problem.
@GeorgeStocker We iterated on some code in a JS fiddle that was linked in the comments, but now that they've been hidden/deleted, I don't have the links anymore...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.