$(document).ready(function(){ }); miss ";" ?
On Oct 27, 9:15 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > Hi, > > 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, please help, > Thanks. > > A.C. > > <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" > "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> > <html xmlns="http://www.w3.org/1999/xhtml"> > <head> > <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 > $(document).ready(function(){ > }) > */ > function foo() { > var s = document.getElementById( "02" ); > s.selected = true; > s.defaultSelected = true; > > }; > > </script> > </head> > > <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> > > </select> > </form> > </body> > </html>