ericbae
ericbae

Reputation: 9644

jQuery removeAttr('selected') doesn't change the view

I have a multi-select form.

And I am doing the following via jQuery to "unselect" all the options.

$('#select').find('option').attr('selected', false);

Programmatically, it works. However, on the actual page, the option is still highlighted in GREY.

BUT, when I scroll down until that option is not visible and then scroll back up, the grey-highlighting is gone. I'm using Chrome.

I checked it in Firefox, and it works fine. Is this a Chrome bug?

Upvotes: 1

Views: 649

Answers (2)

Lochlan
Lochlan

Reputation: 101

Could also try:

$('#select').find('option').removeAttr('selected');

Upvotes: 0

ysrb
ysrb

Reputation: 6740

Try setting it to the default value.

$('#select').val("");

Upvotes: 4

Related Questions