I was wondering how I can loop through html menus with jQuery just like in text fields e.g.
$("#table input['type=te开发者_如何学运维xt']").each(function(){
});
How do I do the same for drop down menus?
Just change the selector to match the elements in the <select>
element, which are <option>
elements:
$("#select option").each(function(){
});
To loop through your menu items or any element just specify which class or element you want to loop through.
List:
$("#menu li").each(function(){
alert($(this).val()); // Alert demonsatrating option value
});
Dropdown's
$("#menu option").each(function(){
alert($(this).val()); // Alert demonsatrating option value
});
精彩评论