2

I everybody,

I've a multi-select like this:

<select multiple="multiple" id="lista">
    <option value="a">Mario</option>
    <option value="b">Maria</option>
    <option value="c">Mark</option>
</select>

How can I prevent to select multiple option by a user? (shift+arrow up/down)

thanks in advance

ciao h.

4

2 回答 2

2

您需要为其提供 size 属性..

<select id="lista" size="3">
    <option value="a">Mario</option>
    <option value="b">Maria</option>
    <option value="c">Mark</option>
</select>
于 2013-03-15T17:52:54.590 回答
2

Although I'm not sure why you can't simply remove multiple="multiple" in the HTML, here's how you would do it with jQuery:

// Wait until the DOM is loaded
$(function(){
    $('#lista').removeAttr("multiple");
});
于 2013-03-15T17:51:30.140 回答