大佬教程收集整理的这篇文章主要介绍了jQuery,点击事件,过多的递归,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
$('#places-view > tbody').find('td').click(function(evt) { var td = $(this),input = td.find('input'); console.log('click'); console.log(input.attr('disabled'),'disabled'); if (! input.attr('disabled')) { input.trigger('click'); console.log('inner click'); } })
抛出过多的递归错误……
问候
$('#places-view input').click(function(event) { // This will prevent the click event from bubbling up and firing // the click event on your <td> event.stopPropagation(); // run the rest of your click code });
http://api.jquery.com/event.stopPropagation/
编辑:正如@pointy所指出的那样,你可能希望让同一个处理程序处理这两个事件,或者至少让你在点击输入时触发td处理程序.
如果是这种情况,您只需要检查td处理程序是否通过单击输入触发,如果是,则阻止input.trigger(“click”)运行:
$('#places-view > tbody').find('td').click(function(evt) { var td = $(this),'disabled'); if (! input.attr('disabled')) { // If the target of the click was not the input,// then trigger the click on the input if( input.not( evt.target ).length ) { input.trigger('click'); console.log('inner click'); } } });
另一种进行测试的方法是:
if(input[0] != evt.target) {...
以上是大佬教程为你收集整理的jQuery,点击事件,过多的递归全部内容,希望文章能够帮你解决jQuery,点击事件,过多的递归所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。