Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Translate onLoad to jQuery 1

Status
Not open for further replies.

BigRed1212

Technical User
Mar 11, 2008
550
0
0
US

Hi,

I'm looking to translate:

window.onload=function(){
document.getElementById("states").selectedIndex =
document.getElementById("states").getAttribute("default");
}

to jQuery.

I've tried a number of combinations like:

$(document).ready(function(){
$("#states").selectedindex= ("default");
});

with no joy. I am just guessing at this point.

Any insight (accompanying explanations and tutoring warmly welcomed)?

 
Code:
$(function(){  
    $("#states").val("default");
});
BTW, jquery has an excellent forum which would be the best place to get answers about jquery. TT works, but I find it's better to go straight to the source.

another great reference is the jquery documentation.

Jason Meckley
Programmer

faq855-7190
faq732-7259
 
$(document).ready(function(){
$("#states").val("default");
});


seems to do the trick. Thanks!

I hadn't joined the jQuery forum yet and I like this place so I posted here.

Although touted very highly and recommended frequently in the Googling I have done, I personally find that site almost devoid of usefulness, but thanks anyway.
 
LOL. That is funny. That is actually the one book I had settled on after looking at several. Apparently I knew what I was doing. Hah! I just hadn't bought it yet because I hate that technical books start at like $45.

Thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top