jQuery Set Select Index

后端 未结 24 1720
无人共我
无人共我 2020-11-27 09:52

I have an select box:


  
  
  



You can also call this before changing the selectedIndex if what you want is the "selected" attribute on the option tag (here is the fiddle):

$('#selectBox option').removeAttr('selected')
   .eq(this.selectedIndex).attr('selected','selected');

提交回复
热议问题