Skip to main content

Bug Tracker

Side navigation

#10472 closed bug (invalid)

Opened October 11, 2011 10:08AM UTC

Closed October 11, 2011 01:13PM UTC

Last modified February 10, 2013 03:29PM UTC

jquery-1.6.2 not changing select (default) element in Firefox when default is first

Reported by: Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: 1.6.4
Keywords: Cc:
Blocked by: Blocking:

Attempting to change the value of select drop-down fails without error on Firefox 7.0.1 when the option changing from is the first option in the list.

I tested this on Chrome and Safari and found it to work as expected.

The script used is as follows:

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN">
		<script src="js/jquery-ui-1.8.16.custom/js/jquery-1.6.2.min.js" type="text/javascript"></script>

		<div class="chrtTimeSelect">
			<select id="chrt_time">
				<option value="1" selected="selected">24 hours</option>
				<option value="2">6 months</option>
				<option value="3">1 year</option>
				<option value="4">5 years</option>
				<option value="5">10 years</option>
				<option value="6">20 years</option>



				var time_selection = "5";

				$("#chrt_time option[selected]").removeAttr("selected");
				$("#chrt_time option[value=" + time_selection + "]").attr("selected", "selected");



Attachments (0)
Change History (4)

Changed October 11, 2011 01:13PM UTC by dmethvin comment:1

resolution: → invalid
status: newclosed

Attributes aren't dynamic. Use .val() on the select or .prop() on the option element you want to select:

Changed July 16, 2012 02:23PM UTC by comment:2

It didn't work even if i use .val()...

Changed February 10, 2013 03:26PM UTC by anonymous comment:3

I have the same problem... Someone found any solution?

Changed February 10, 2013 03:29PM UTC by anonymous comment:4

// Solution founded! Use ".removeAttr("selected").removeAttr("selected")".