简体   繁体   中英

Jquery chosen trigger method doesn't work

I'am using jquery-chosen plugin . I want to set option "selected" by index value. Following codes are working right but I guess the plugin has a bug.

Because when I give number upper than zero it works fine but when I give zero it doesnt work . How I can fix it ? Thanks in advance

$('#mySlelectID').val(index).trigger('chosen:updated');

There are so many issue in your code, firstly your option tags do not have value attribute in it, secondly jquery library is not included in your jsfiddle example. After resolving these issue, you can make any value selectd by using:

jQuery('.chosen').val(1).change();

Updated Fiddle

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM