apply css class onmouseover and remove onmouseout using javascript

Recommended Answers

All 2 Replies

what is your specific question?
well if i could undestand the question
here a sample code:

<!DOCTYPE html>
<html>
<head>
<script>
function bigImg(x)
{
x.style.height="64px";
x.style.width="64px";
}

function normalImg(x)
{
x.style.height="32px";
x.style.width="32px";
}
</script>
</head>
<body>

<img onmouseover="bigImg(this)" onmouseout="normalImg(this)" border="0" src="smiley.gif" alt="Smiley" width="32" height="32">

<p>The function bigImg() is triggered when the user moves the mouse pointer over the image.</p>
<p>The function normalImg() is triggered when the mouse pointer is moved out of the image.</p>

</body>
</html>

If you just want to toggle classes on mouse onmouseover and remove you can use something like this with jQuery :

$(element).hover(function(){ $(this).classToggle('name_of_the_class');}});
you can do the same on function on mouse leave or blurr etc.

Hope this helps.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.