Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In html how to remove onmouseover function

can anyone let me know how to remove (onmouseover="mouseoversound.playclip()") in the below html

<a href="roster.html" onmouseover="mouseoversound.playclip()">Roster</a>

Instead of this can we use in js file i.e. #nav li a hover event play clip. Below is the reference link: javascriptkit.com/script/script2/soundlink.shtml

like image 839
Designing Studios Avatar asked May 03 '26 20:05

Designing Studios


1 Answers

I think that the responders didn't fully read your question. Since the event is bound inline (which someone mentioned IS deprecated) we can just remove the onmouseover attribute within the anchor.

In the example below, I've just attached an onclick inline event. Clicking the link will remove the event bind.

You can do with in straight JavaScript:

<a href="roster.html" onmouseover="mouseoversound.playclip()" onclick="this.removeAttribute('onmouseover')">Roster</a>

Without using an inline onclick on that element, you could just use this:

<a id="Link1" href="roster.html" onmouseover="mouseoversound.playclip()">Roster</a>
<a href="javascript:void(0);" onclick="document.getElementById('Link1').removeAttribute('onmouseover')">Remove onmouseover</a>