Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable javascript in a element

I have an element with a a script for a mouseover to show an image. I can't change the HTML, so is it possible to disable the javascript in the link, but still keep the link for the href intact? I cant use the id of the a element since it isn't unique.

HTML:

 <div class="container">
<a id="a211094" onmouseout="etim();" onmouseover="stim('/imgs/7c24b548-4f4c-418e-ad4f-53c73cf52ace/250/250',event,this.id);" href="/products/Computers/Desktops/Acer/Acer-Aspire-TC-705W-Towermodel-1-x-Core-i3-41?prodid=211094"><img src="" alt="">
</a>
</div>
like image 542
Xeptor Avatar asked Nov 24 '15 13:11

Xeptor


3 Answers

if you want to make all ancher tag or you can give class for those anchor tags on which you want to perform this and instead of $( "a" ) write $( ".myClass" )

$( "a" ).each(function( index ) {
$( this ).removeAttr("onmouseout");
$( this ).removeAttr("onmouseover");
});

use can use attr("disabled", "disable"); to disable it

like image 78
Domain Avatar answered Sep 23 '22 02:09

Domain


Overwriting the JavaScript:

document.getElementById("a211094").onmouseover = null
document.getElementById("a211094").onmouseout = null
like image 26
CoderPi Avatar answered Sep 19 '22 02:09

CoderPi


document.getElementById("a211094").removeAttribute("onmouseout");
document.getElementById("a211094").removeAttribute("onmouseover");
like image 26
Brian FitzGerald Avatar answered Sep 19 '22 02:09

Brian FitzGerald