Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
188
rated 0 times [  193] [ 5]  / answers: 1 / hits: 136504  / 14 Years ago, mon, february 14, 2011, 12:00:00

Basically I want to make this:



<li id=about><a href=#>About</a>


Into this when the page loads:



<li id=about class=expand><a href=#>About</a>


I found this thread, but am not so good with javascript and couldn't adapt it:
Javascript: Onload if checkbox is checked, change li class


More From » onload

 Answers
59

This should work:



window.onload = function() {
document.getElementById('about').className = 'expand';
};


Or if you're using jQuery:



$(function() {
$('#about').addClass('expand');
});

[#93740] Saturday, February 12, 2011, 14 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
marint

Total Points: 550
Total Questions: 105
Total Answers: 124

Location: Zambia
Member since Sat, Oct 31, 2020
4 Years ago
;