bootstrap-select

How to set selected value on select using selectpicker plugin from bootstrap

徘徊边缘 提交于 2019-11-26 09:25:19
问题 I\'m using the Bootstrap-Select plugin like this: HTML : <select name=\"selValue\" class=\"selectpicker\"> <option value=\"1\">Val 1</option> <option value=\"2\">Val 2</option> <option value=\"3\">Val 3</option> <option value=\"4\">Val 4</option> </select> Javascript : $(\'select[name=selValue]\').selectpicker(); Now I want to set the value selected to this select when button clicked... something like this: $(\'#mybutton\').click(function(){ $(\'select[name=selValue]\').val(1); }); But