jquery给A标签注册click事件后无法触发
RT 使用jq each函数对页面a标签注册click事件
场景:点击A标签,事件触发;点击button触发函数中使用$("#a标签id").click();却无法触发相应a标签事件
问题:为啥以委托触发的形式无法触发事件呢?
期待高手解释一下...... jQuery
[解决办法]
楼主上代码吧,不然看不出哪里有问题
我自己写了个小测试,完全没问题。
[解决办法]
<a id="a" href="http://www.baidu.com">baidu</a>
<br />
<button id="button">click</button>
<script type="text/javascript">
document.getElementById("a").onclick = function() {
alert("触发A标签click事件");
};
document.getElementById("button").onclick = function() {
document.getElementById("a").onclick();
};
</script>
$.("a").each(function(){
$(this).on("click",function(){
alert(123);
});
});
$(document).ready(function(){
$("a").click(){
alert(this.id);
}
}