Skip to main content

Bug Tracker

Side navigation

#1851 closed bug (worksforme)

Opened October 27, 2007 03:55AM UTC

Closed December 04, 2007 08:11AM UTC

jQuery stops javascript to update selected = true in Safari

Reported by: angelochen960 Owned by:
Priority: major Milestone: 1.2.1
Component: core Version: 1.2.1
Keywords: safari select Cc:
Blocked by: Blocking:

I try to set a selected option in a Select box, the following code

works without jQuery function defined, once I un-comment the jQuery

part, it works in Firefox, but not in Safari any more.

<!DOCTYPE html PUBLIC "-W3CDTD XHTML 1.0 TransitionalEN" "http:">

<html xmlns="">


<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

<title>Untitled Document</title>

<script type="text/javascript" src="jquery-1.2.1.js"></script>

<script type="text/javascript">

/* un commenting this will cause safari to fail




function foo() {

var s = document.getElementById( "02" );

s.selected = true;

s.defaultSelected = true;




<body onload="foo();">

<form id="form1" name="form1" method="post" action="">

<select name="state" id="state">

<option id="01" value="NY">New York</option>

<option id="02" value="AL">Alaska</option>

<option id="03" value="KY">Kentuky</option>

<option id="04" value="IA">IOWA</option>





Attachments (0)
Change History (1)

Changed December 04, 2007 08:11AM UTC by davidserduke comment:1

resolution: → worksforme
status: newclosed

I suggest if you are using jQuery to take out the onload attribute from body and put the foo function call in the document ready function like:

$(document).ready(function () {

It is possible there may be problems with some browser versions when using body onload and the document ready functionality.

That said, I was unable to reproduce this bug in Safari 3 Win. So if this really is a problem and there is a specific version that failed please reopen the bug with that information.