How can I change the unselected item to selected item from dropdown list without using the iterator function in Jquery?
How can I change the unselected item to selected item fro开发者_JAVA百科m dropdown list without using the iterator function in Jquery?
Two notes before the answer.
- selected="true" for HTML, selected="selected" for XHTML
- Multiple selections need to be enabled on the select
Here is the jQuery "not" selector in action.
$("select option:not(:selected)").attr("selected", "true");
精彩评论