Web Development Ninjas Question:
Download Job Interview Questions and Answers PDF
Tell me how do you find all the selected options of HTML select tag?
Answer:
This is one of the tricky jQuery question on Interviews. This is a basic question, but don’t expect every jQuery beginner to know about this. You can use the following jQuery selector to retrieve all the selected options of <select> tag with multiple=true :
$('[name=NameOfSelectedTag] :selected')
This code uses the attribute selector in combination of :selected selector, which returns only selected options. You can tweak this and instead of name, you can even use id attribute to retrieve
<select> tag.
$('[name=NameOfSelectedTag] :selected')
This code uses the attribute selector in combination of :selected selector, which returns only selected options. You can tweak this and instead of name, you can even use id attribute to retrieve
<select> tag.
Download Ninjas Web Developer Interview Questions And Answers
PDF
Previous Question | Next Question |
Do you know what is the difference between jQuery.get() and jQuery.ajax() method? | Explain me what is the difference between <div> and <frame>? |