I have a click event which works fine in all other browsers except IE8
I tried
document.getElementById('xxx').click -- returns function called
document.getElementById('xxx').click() -- object not supported
document.querySelectorAll('xxx').click -- not supported
$("#xx").trigger("click") -- not supported
$(".xx").trigger("click") --not supported
In html i have <div id="xxx" click="functionname('param1','param2')"></div>
Now the document.getElementById('xxx').click
returns the function returned
ie functionname(param1,param2)
How can call this function at this time? like i want to execute this function
Add function bracket. Otherwise you will get function definition
document.getElementById('xxx').click()
or
var evt = document.createEvent("MouseEvents");
evt.initMouseEvent("click", true, true, window, 1, 0, 0, 0, 0,
false, false, false, false, 0, null);
var cb = document.getElementById(id);
cb.dispatchEvent(evt);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.