Js chosen, how to update the dropdown when there is an update in the select option

41 Views Asked by At

i use chosen js for my select option

but in my case there is some button that can trigger some section to be hidden, so i want to update my dropdown to hide the section too.

this in before the section is hidden

<select id="course" name="" class="form-select chosen-select">
<option value="topbar">Jump to section</option>
<option id="sec1" value="section1">Section 1</option>
<option id="sec2" value="section2">Section 2</option>
<option id="sec2" value="section3">Section 3</option>
</select>

how to update the dropdown when the select option become like this

<select id="course" name="" class="form-select chosen-select">
<option value="topbar">Jump to section</option>
<option style="display:none;" id="sec1" value="section1">Section 1</option>
<option id="sec2" value="section2">Section 2</option>
<option id="sec2" value="section3">Section 3</option>
</select>

I already try .trigger("chosen:updated") and .trigger("liszt:updated) but still the dropdown not changing, i think i maybe use it wrong but the documentation about chosen is so few. please someone help me :) thanks

Update chosen js dropdown

0

There are 0 best solutions below