tijger0407 Posted April 7, 2010 Share Posted April 7, 2010 Currently having this code <script language="javascript" type="text/javascript"> function changecolor(){ document.getElementByClass('menu').style.backgroundColor='#FFFFFF'; } function revertcolor(){ document.getElementByClass('menu').style.backgroundColor='#565656'; } </script>and <a href="home.php" alt="Me"> <div class="menu" onmouseover="changecolor()" onmouseout="revertcolor()"> <p>Me</p> </div> </a>Now I want to change the background of the div with the mouse over used by the functionATM it aint working and not having a clue why it aint workingAny help would be apriciated Link to comment Share on other sites More sharing options...
thescientist Posted April 7, 2010 Share Posted April 7, 2010 I'm pretty sure there's no such thing as getElementByClass.maybe this might help instead? http://www.w3schools.com/jsref/met_doc_getelementsbyname.aspor give it an ID an use getElementById instead, which I believe is the preferred way of doing it. Link to comment Share on other sites More sharing options...
jeffman Posted April 7, 2010 Share Posted April 7, 2010 The method is getElementsByClassName(), and it is not consistently implemented. You can build a collection using getElementsByTagName() and then loop through it to filter the className property. That's a pretty common technique. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.