jquery select2的使用心得(推荐)
ajax加载下拉框数据后如何选中指定项?
html:
<script src="/statics/matrix-admin/js/jquery.min.js"></script> <script src="/statics/matrix-admin/js/select2.min.js"></script> <select id='mySelect'></select>
js:
$(function(){ $('#mySelect').select2(); $.ajax({ success:function(data){ $('#mySelect').append(); $('#mySelect').select2('val','val1');//调用select2('val','指定项value')方法选中指定项,否则无任何项被选中。如果设置的值不存在,则默认选择第一项 } }) })
相关推荐
chongxiaocheng 2019-12-13
84483065 2016-03-22
winnie0 2015-10-08
msyndra 2015-09-15
uvyoaa 2015-01-16
xiaochuachua 2013-06-12
富贵 2013-05-06
yybb0 2018-08-09
czFive 2018-08-09
DuKeCan 2017-10-12
gamecalo 2017-05-19
83453861 2017-03-20
81413460 2016-10-24
lxl000 2019-04-26
89387341 2019-04-25
XTUxiaoxin 2016-05-06
Jensony 2016-04-15