Jump to content

referring to an ID


novicenate

Recommended Posts

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

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

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...