This is a split board - You can return to the Split List for other boards.

Help with a HTML code line

#1TeritoclonePosted 8/30/2013 4:22:04 PM
Here's what I have:

<li><a href="#" onClick="setActiveStyleSheet('blue'); return false;"><span class="pre-color-skin4"></span></a></li>

Basically, when the user clicks the button, blue happens.

However, how do I script this so as soon as the page is loaded (no user interaction), blue happens?

Thanks :)
---
Kevin sent me.
PSN: Tigermisu
#2iceachePosted 8/30/2013 4:26:54 PM
Remove the "OnClick" part?
#3Teritoclone(Topic Creator)Posted 8/30/2013 4:28:01 PM
iceache posted...
Remove the "OnClick" part?


That would make it so it doesn't change at all.
---
Kevin sent me.
PSN: Tigermisu
#4TheWayOfTheGunPosted 8/30/2013 4:40:49 PM(edited)
If you want to set that html element to blue or whatever css properties on page load then make a ondocument load script block and then set it.

I would use jquery since it makes it super easy and its syntax is based on css selectors.

$(function(){
$('a').css('background-color', 'blue');
});


There are a dozen ways to accomplish this but the best way is to just use CSS since you want it to happen on page load. You don't even need a script. Just give it a class and style it in a css sheet.


If you wanted to change the color on mouse click it's much cleaner and easier in jQuery also,

$(function(){
$('a').click(function() { $(this).css('background-color', 'blue'); } );
});