【发布时间】:2015-02-26 11:00:19
【问题描述】:
这是一个简单的要求,但是我使用的是多选插件,因此我无法调试。请帮忙
我正在使用多选下拉插件 - http://www.erichynds.com/blog/jquery-ui-multiselect-widget
这是我的html:
<select id="example2" name="example" multiple="multiple" class="multiselect" onclick="filterLocation();">
<option id="aa" value="Ready">Ready</option>
<option id="bb" value="Overdue" >Overdue</option>
<option id="cc" value="Pending" >Pending</option>
<option id="dd" value="Cancelled">Cancelled</option>]
This is my javascript:
j$(document).ready(function() {
j$("select.multiselect").multiSelect();
j$("#example2").val("Pending");
});
我想在加载页面时设置值“待定”。但是它在 UI 中不可见。我尝试了以下选项来使用 jquery 设置值,但它不起作用:(
j$('#example2').find('option[value="Pending"]').attr(selected, selected);
document.getElementById('bb').selected= true;
document.getElementById('bb').checked= true;
您能否建议我为什么在使用插件时不检查/选择值?
请看附上的截图..
非常感谢。任何建议都非常感谢
【问题讨论】:
-
你试过api.jquery.com/prop 吗?
$('#bb').prop('selected',true) -
是的..我也试过这个..看起来我需要在插件中改变一些东西。但不知道具体该怎么做:(
-
有人可以帮忙吗?在此先感谢.. 我在插件中也找不到任何问题
-
在演示github.com/ehynds/jquery-ui-multiselect-widget/tree/master/… 中,有预选的演示。这样你就可以选择选项
标签: javascript jquery