Hi,
I am trying to style a parent element with a hover state style. I want to change the background colour when hovered over. I cant edit the html as this is generated automatically from a cms.
HTML example
<td>
<a>
<div id=timetablemenu>Timetable</div>
</a>
</td>
Javascript
var timetablemenuTag = document.getElementById('timetablemenu');
timetablemenuTag.parentNode.parentNode.style.backgroundColor='#FF0000';
This works fine but i need to add a rollover background colour change.
I have tried timetablemenuTag.parentNode.parentNode.addClass="timetable2"; and adding CSS but this doesnt seem to work.
I edited my example (by adding "p.class = p.className", for different browsers use different attribute names). Maybe you're using IE (which uses "class" attribute).
The other possibe reason could be that both CSS styles (.timetable2 and .timetable2:hover) actually set the background color to "green" so no change would occure.
Thanks for your posts.
I have tried this but no luck. I dont get green at all lol. I've tried IE and Firefox.
Manually entering the class into the html works and it displays green but the javascript does seem to be adding the class to the HTML.
Bookmarks