I'm trying to make an JS, but since I'm not an expert on that, maybe someone could help me. I was searching for that in Google and in Stack Overflow, but didn't find what I need. I just found onmouseover
that change the class in element itself. But I want something different:
I want to make a onmouseover
on a
tag to change the class closed
to open
in other element. Example:
<a href="#" onmouseover="<active event>">Link</a>
<ul class="dropdown closed"><li>Item</li></ul>
Regards,
You can use <a href="#" onmouseover="changeClass">Link</a>
And JS:
function changeClass() {
document.getElementById("other-element").className = "open";
}
More advanced JSFiddle: http://jsfiddle.net/eRdHJ/1/
If you include jQuery:
Add id for your elements:
<a href="#" id="a1">Link</a>
<ul class="dropdown closed" id="ul1"><li>Item</li></ul>
Javascript:
$("#a1").mouseover(function(){
$("#ul1").addClass("open").removeClass("closed")
})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With