开发者

jQuery: how to select multiple items in a html dropdown list?

I would like to know how can I use jQuery to select mu开发者_StackOverflow中文版ltiple items without having to press the SHIFT button on my keyboard in a simple html dropdown element:

<select>
<option></option>
<option></option>
<option></option>
</select>

thanks


Given:

<select multiple="multiple" id="foo">
<option>1</option>
<option>2</option>
<option>3</option>
</select>

Do this:

$('#foo option').attr('selected', 'selected');

That would select all of them. That's the best I can give you, without a more specific question.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜