Chrome and reset select using jQuery

0 like 0 dislike
10 views
There is a line written in jQuery:

$('#styleGallery option:selected').removeAttr('selected');

That should reset the selection in the select element.
In FF all works on hurrah, and after the line becomes active the first item in the list.
In Chrome, select reset. And active becomes "empty string" which chrome is added in the select element.

How to do so in both lines you can "reset" the select item select?
by | 10 views

5 Answers

0 like 0 dislike
I would have done:
\r$("#select").val($("#select option:first").val());
by
0 like 0 dislike
Unsure, but try:
$('#styleGallery option:first').attr('selected','selected');
by
0 like 0 dislike
Or this:
\r
$('select option:first').attr('selected','1');
by
0 like 0 dislike
The first option element to add the attribute selected.
by
0 like 0 dislike
For select-class data-filter it will look like this:
\r
\r$('select.data-filter').prop('selectedIndex',0);
by

Related questions

110,608 questions
257,186 answers
0 comments
28,757 users