Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you change the selected option of a jquery selectric element using javascript?

I can change the original select's selected option by doing something like-

$('#mySelectList option:first').prop('selected', true)

but that doesn't update the selectric display of the select.

like image 657
Mike Hensley Avatar asked Jun 26 '14 18:06

Mike Hensley


1 Answers

According to this pull request, you can "refresh" the plugin:

$('#mySelectList').prop('selectedIndex', 0).selectric('refresh');

From the documentation:

$('select').selectric('refresh'); // Reconstruct the instance of plugin

like image 193
Felix Kling Avatar answered Oct 07 '22 17:10

Felix Kling