jQuery prevent change for select

前端 未结 13 1380
無奈伤痛
無奈伤痛 2020-11-28 10:51

I want to prevent a select box from being changed if a certain condition applies. Doing this doesn\'t seem to work:

$(\'#my_select\').bind(\'change\', funct         


        
13条回答
  •  天涯浪人
    2020-11-28 11:35

    This worked for me, no need to keep a lastSelected if you know the optionIndex to select.

    var optionIndex = ...
    $(this)[0].options[optionIndex].selected = true;
    

提交回复
热议问题