simnorwebdesign
Aug 10th 2007, 4:34 am
Hi, I am currently creating a wordpress theme and as part of the theme there is the option for the user to change the colors of the theme, I am using some javascript to change certain elements of the css, but have come up against a problem.
I need to change the h2 property in the #sidebar div, in the CSS file it looks like this:
#sidebar h2 {
styles here
}
The javascript I am using is this:
<script type="text/javascript">
function changetored(){
document.getElementById("header").style.background = "url(<?php bloginfo('stylesheet_directory'); ?>/images/bannerred.png)";
document.getElementById("page").style.background = "url(<?php bloginfo('stylesheet_directory'); ?>/images/shadowred.png)";
}
</script>
Now this works fine because it is getting the Element, however what I want to change is the background color of not an element but a class (h2) or more particularly #sidebar h2
How would I do this, is getElementById supposed to be something different?
Any help will be greatly appreciated, thank you
Simon North
I need to change the h2 property in the #sidebar div, in the CSS file it looks like this:
#sidebar h2 {
styles here
}
The javascript I am using is this:
<script type="text/javascript">
function changetored(){
document.getElementById("header").style.background = "url(<?php bloginfo('stylesheet_directory'); ?>/images/bannerred.png)";
document.getElementById("page").style.background = "url(<?php bloginfo('stylesheet_directory'); ?>/images/shadowred.png)";
}
</script>
Now this works fine because it is getting the Element, however what I want to change is the background color of not an element but a class (h2) or more particularly #sidebar h2
How would I do this, is getElementById supposed to be something different?
Any help will be greatly appreciated, thank you
Simon North