1

There are two multiselects used in my project, a single select and a multiple select. At first, they are disabled and show right(display the noneSelectedText value). If I enable them, the single select always automatically select the first option, and the multiple one show right.Then disable them, both of them show right again. My question is that how can I stop the single select one from automatically selecting the first option? I tried to uncomment the code following in the source code of multiselect,

    // browsers automatically select the first option
    // by default with single selects
    if(isSelected && !o.multiple) {
      labelClasses.push('ui-state-active');      
    }

but it does not work. Did I miss something or do something wrong?

4

1 回答 1

1

您可以使用不可选择的选项来执行此操作:

<select placeholder="coudcou">
    <option val="null" disabled selected> select an answer</option>
    <option val="one">one</option>
</select>

$('select').on('change', function(){
    $('select option:disabled').remove();
});

小提琴:http: //jsfiddle.net/bd4R7/1/

于 2013-09-26T07:06:49.723 回答