Alright guys, Im using this code to change the style of a div: document.getElementById("holder").style.background = "#ccccccc"; This is working great. BUT i want to also change the way the links appear, i imagined it would be this: document.getElementById("holder a").style.background = "#ccccccc"; But its not. im basicly trying to dynamically change: .holder a { background-color:#CCCCCC; } Any help on how to do this would be sweet. Cheers.
Could you please explain the solution? I am in the similar situation and still in dark with the solution above
he defines a clas in css, like .holder a { background-color: #ccc; } on the event, he adds the classname to parent element which then makes the pseudo selector .holder a work. if you use a framework like mootools or jquery, you can actually reference the anchor links directly: // this in the context of a function run on mouseover on holder... this.getElements("a").setStyles({background: '#ccc',color: 'red'}); // a more generic one for all links $$("div.holder a") // just 1 $E("div.holder a") // same as $$("div.holder a")[0] this.getElement("a"); this.getFirst(); // if it is first :D // all secure anchor links with href="https*" (starting with) this.getElements("a[href^=https]"); PHP: etc etc. go on, get a framework