Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I add onmouseover attribute to run only once?

Say I have a link like the following:

<a class="link" href="www.rich.com" onmouseover="go(this)">Link</a>

Is there a way to configure the onmouseover event, calling go(this) to run only a single time while still using the inline onmouseover=<some code> notation? I want it defined inline, not with a JavaScript call.

Currently, I have this, but it is not what I want:

$(".link").one('mouseover', function(e) {
     // do something
});
like image 345
Rich Episcopo Avatar asked Oct 01 '15 19:10

Rich Episcopo


1 Answers

You can nullify the onmouseover binding afterwards:

<a class="link" href="www.rich.com" onmouseover="go(this); this.onmouseover = null;">Link</a>
like image 88
taxicala Avatar answered Sep 21 '22 01:09

taxicala