Generating A Click Event On ....... Using Javascript
I have a grid of divs which represents a map. I want to be able to generate click event on any of the div as I click with my mouse. I have used following code snippet with no succe
Solution 1:
My answer to this SO question presented this function, which may be useful:
functioneventFire(el, etype){
if (el.fireEvent) {
el.fireEvent('on' + etype);
} else {
var evObj = document.createEvent('Events');
evObj.initEvent(etype, true, false);
el.dispatchEvent(evObj);
}
}
Here's another SO question on this subject
Solution 2:
Solution 3:
why not use jquery?
$('#someID').click();
I do think that there may be ways to distinguish mouse clicks and triggered clicks: the x/y position of a triggered click may not match the position of the element clicked.
Solution 4:
use the jquery click event to fire a function. it's easier.
Post a Comment for "Generating A Click Event On ....... Using Javascript"