Arjunan Arjun
Arjunan Arjun

Reputation: 125

Add a Mouseover Event Dynamically on a HTML Element

I have an HTML element like this:

<div id="new"></div>

I want to append a onmouseover function to append text to this element like this:

<div id="new" onmouseover="show_pop()"></div>

What is the jQuery function for this?

Upvotes: 0

Views: 3142

Answers (1)

The Busy Wizard
The Busy Wizard

Reputation: 1166

You want:

$('#new').mouseover(function() {show_popup();});

Or, if you REALLY want it to actually add that to the node (which you probably don't), then something like:

$('#new').attr('onmouseover', 'show_popup()');

Upvotes: 1

Related Questions