How to add events to a dynamically created Div’s in JavaScript ?

Use the following JavaScript code

// If you are using Internet Explorer as your browser

divId.attachEvent(‘onclick’, clickEvent);
divId.attachEvent(‘onmousemove’, mousemoveEvent);

Note : divId would be Id of the dynamically added Div.

function clickEvent()
{
alert(“i am in click”);
}

function mousemoveEvent()
{
alert(“i am in mousemove”);
}

Enjoy…..

Saurabh D / Pawan Kumar
Pawankkmr@hotmail.com

Advertisements