View Single Post
Old 01-17-2013, 09:58 PM   PM User | #1
ajhauser
Regular Coder

 
ajhauser's Avatar
 
Join Date: Nov 2007
Location: Earlville. It's where Earls come from.
Posts: 224
Thanks: 73
Thanked 1 Time in 1 Post
ajhauser is an unknown quantity at this point
Add class to body to randomize background via CSS

Hey all, I was hoping to get some help with this one. How would I add a class (which will be randomized) to my body tag if the initial class is either "templateCollection" or "templateProduct"?

So for example, IF my body tag looks like this:

Code:
<body class="templateProduct">
Add a class to it:

Code:
<body class="templateProduct randomizeBackground">
I'm open to suggestions on this one...

I tried using the following type of JS, but I can't seem to get anywhere with it:

Code:
<script type="text/javascript">document.getElementsByTagName('body')[0].className+=' randomizeBackground'</script>
Thanks!
ajhauser is offline   Reply With Quote