[英]jQuery trigger click on element with “onclick” attribute
I have an input element with onclick
attribute attached to it: 我有一个带有
onclick
属性的input元素:
<input id="" type="radio" name="" value="" onclick="SetUniqueRadioButton('rptrDelRates.*grpDelRate', this);">
Everything is working good, but when I decide to trigger click manually on this element using jQuery
I get the error below: 一切都运行良好,但当我决定使用
jQuery
手动触发此元素时,我得到以下错误:
Invalid regular expression: /rptrDelRates.*grpDelRate/: Stack overflow
无效的正则表达式:/rptrDelRates.*grpDelRate/:堆栈溢出
jQuery call: jQuery调用:
$('.setup-radio').on('click', function () {
$(this).find('input').trigger('click');
return false;
});
you can call the native doms onclick directly: 你可以直接调用本地doms onclick:
$(".setup-radio")[0].onclick();
without jquery: 没有jquery:
document.getElementsByClassName("test_default")[0].onclick();
your SetUniqueRadioButton function must add event.stopPropagation(); 你的SetUniqueRadioButton函数必须添加event.stopPropagation();
code may case loop because of bubble 由于泡沫,代码可能是case循环
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.