Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

adding a mouseover to a link through javascript

Simple quick question....

I have the following link html:

<a href="http://www.site.com/" onmouseover="" />

I have a javascript function which I want to enter some onmouseover information into that link dynamically. So, lets say it then becomes this for example if this javascript function is called:

<a href="http://www.site.com/" onmouseover="alert('howdy')" />

any ideas how to do this?

like image 336
David Avatar asked Feb 02 '11 10:02

David


People also ask

What does mouseover do in JavaScript?

The mouseover event is fired at an Element when a pointing device (such as a mouse or trackpad) is used to move the cursor onto the element or one of its child elements.

What is a mouseover link?

Alternatively referred to as mouseover or mouse hover, hover describes the act of moving a mouse cursor over a clickable object, but not actually clicking the left or right mouse button. For example, when you hover your mouse over any of the links on this page, they should change color, indicating they can be clicked.


1 Answers

Add name attribute to and assign onmouseover

<a href="http://www.site.com/" onmouseover="" name="xxx"/> 
document.getelementsbyname('xxx').onmouseover = function() { alert('howdy') } 
like image 65
RameshVel Avatar answered Sep 26 '22 01:09

RameshVel