Can't execute click()
on generated ajax a
element. But I can select.
function cansel(){
var cansel_button = document.getElementById('cansel_button');
console.log(cansel_button);
console.log('post');
cansel_button.click();
}
And I got this log:
<a id="cansel_button" style="text-decoration:none;" class="" onclick="">…</a>
post
extensions/event.js:185Error in event handler for 'undefined': TypeError: Object has no method 'click'
at cansel (unknown source)
at unknown source
at [object Object].dispatch (extensions/event.js:183:28)
at Object.<anonymous> (extensions/miscellaneous_bindings.js:177:22)
And yes, this is injected script from chrome extension.
UPD: Injected page have trigger like $('#element').live('click', function(){ })
and I need to execute this without any hacks.
document.getElementById method returns DOM Element , which does not have "click"
method you were trying to call. If you want to call click
handler, then you need to use this:
cansel_button.onclick();
instead of cansel_button.click();
.
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.