bootstrap select js operation

3.2, component assignment

Component assignment you need to transform a little bit, and if you just $ ( '# sel') val ( '1'); this assignment will be invalid, the correct assignment method:

$ ( 'selectpicker.') selectpicker ( 'val', '1');.
In some cascading selected usage scenarios, often need to look at the way the trigger when an assignment change event components, we can do it.

$ ( 'selectpicker.') selectpicker ( 'val', '1') trigger ( "change");..
if it is multiple choice assignment, it is the same

$('.selectpicker').selectpicker('val', ['1','2','3']).trigger("change");

全选: $('.selectpicker').selectpicker('selectAll');

反选: $('.selectpicker').selectpicker('deselectAll');

Adaptation phone mode: $ ( 'selectpicker.') Selectpicker ( 'mobile');.

Component is disabled:

( '.disable-example') selectpicker ( 'refresh');.
component is enabled:

. ( '.disable-example') selectpicker ( 'refresh');
component destruction:

$('.selectpicker').selectpicker('destroy');

Guess you like

Origin blog.csdn.net/weixin_34289454/article/details/90866493