Bug Tracker

Modify

Ticket #11488 (closed bug: invalid)

Opened 14 months ago

Last modified 3 weeks ago

Setting select attribute doesn't change dropdown position in firefox

Reported by: anonymous Owned by:
Priority: low Milestone: None
Component: attributes Version: 1.7.1
Keywords: Cc:
Blocking: Blocked by:

Description

Firefox 9 & 11 under Windows 7 Professional

The dropdown HTML:

<select id="periodSelect" name="periodSelect">
<option value="0" selected>Choose period</option>
<option value="9">2011, P01</option>
<option value="11">2012, P01</option>
<option value="2">011, P10</option>
<option value="1">2013, P01</option>
</select>

jquery code:
$('#periodSelect option').removeAttr('selected');
$("#periodSelect option[value='11']").attr('selected',true);

description: The code, when executed for the first time, doesn't chenge what I can se in the dropdown. When executed for the second time it makes the change. The change happens also when I select an option from the drop down and then execute the code.

working example (not working in Firefox):
 http://jsfiddle.net/LXz8J/

The code works for latest version of chrome (17) and IE8

Change History

comment:1 follow-up: ↓ 2 Changed 14 months ago by sindresorhus

  • Priority changed from undecided to low
  • Resolution set to invalid
  • Status changed from new to closed
  • Component changed from unfiled to attributes

Not really a jQuery bug since it's reproducible using native DOM methods too (in Firefox, not Chrome):  http://jsfiddle.net/scjK9/

To get it to work, you can remove the first line. You don't actually need to remove the 'selected' property before adding it to a option element. Just add it directly and the browser will be smart enough to switch to the recently selected option element.

comment:2 in reply to: ↑ 1 Changed 3 weeks ago by anonymous

Replying to sindresorhus:

Not really a jQuery bug since it's reproducible using native DOM methods too (in Firefox, not Chrome):  http://jsfiddle.net/scjK9/

To get it to work, you can remove the first line. You don't actually need to remove the 'selected' property before adding it to a option element. Just add it directly and the browser will be smart enough to switch to the recently selected option element.

The code in the changed history is not working at all, so the bug is stell open!!!

comment:3 Changed 3 weeks ago by timmywil

@anonymous: use properties, not attributes.  http://jsfiddle.net/timmywil/xyH32/

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.