How to reset select select with jquery using chrome?

I just want to clear the html selectbox selection. The following works fine in Safari and Firefox, but not in Google Chrome:

$('select#selectbox').val(null);

Any ideas?

Whole js here: http://jsfiddle.net/EJgdA/8/

+3
source share
3 answers

.val(null) only works in FF and Opera, so I don't think this is a valid use case.

You can disable everything using selectedIndex as such:

$('#selectbox').prop('selectedIndex', -1);

Please note that .prop()only works in jQuery 1.6+, for lower versions you should use .attr().

+3
source

Interesting. Have you tried plain js?

document.getElementById('selectbox').selectedIndex = -1;
0
source

$('select#selectbox').val(null); value , select .

.

 $("#selectbox").find("option:selected").removeAttr("selected"); 

, jQuery1.6

$('#selectbox').prop('selectedIndex', -1); 
-1

All Articles