novicenate Posted April 7, 2006 Share Posted April 7, 2006 is there a way to refer to an element's ID to the point of making that element perform certain actions as detailed in a function? For example, say I have a bullet list with an ID="listone" and a class="liststyleoff" I want to make it so when that list item is hovered over, the class is changed to "liststyleon" and when the mouse leaves the list item, the class returns to "liststyleoff". thanks Link to comment Share on other sites More sharing options...
Siddhesh Posted April 7, 2006 Share Posted April 7, 2006 is there a way to refer to an element's ID to the point of making that element perform certain actions as detailed in a function? For example, say I have a bullet list with an ID="listone" and a class="liststyleoff" I want to make it so when that list item is hovered over, the class is changed to "liststyleon" and when the mouse leaves the list item, the class returns to "liststyleoff". thanks<{POST_SNAPBACK}> U can call function on OnMouseOver event of that element.and U can refer an element by its id as getElementById("listone").class = "liststyleon" / "liststyleoff"; Link to comment Share on other sites More sharing options...
aspnetguy Posted April 7, 2006 Share Posted April 7, 2006 Actually it would be like this var obj = document.getElementById('idGoesHere');obj.onmouseover = function(){this.className='classForMouseOver'}obj.onmouseout = function(){this.className='classForMouseOut'} Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now