[英]Click to ajax generated 'a' element
Can't execute click()
on generated ajax a
element. 无法执行
click()
上产生阿贾克斯a
元素。 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. 是的,这是从chrome扩展注入的脚本。
UPD: Injected page have trigger like $('#element').live('click', function(){ })
and I need to execute this without any hacks. UPD:注入的页面具有
$('#element').live('click', function(){ })
类的触发器,我需要执行此操作而不会受到任何黑客攻击。
document.getElementById method returns DOM Element , which does not have "click"
method you were trying to call. document.getElementById方法返回DOM Element ,该元素没有您尝试调用的
"click"
方法。 If you want to call click
handler, then you need to use this: 如果要调用
click
处理程序,则需要使用以下命令:
cansel_button.onclick();
instead of cansel_button.click();
而不是
cansel_button.click();
. 。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.