且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

按钮单击事件触发错误的事件处理程序

更新时间:2023-11-30 19:36:04

它被称为'冒泡'。按钮位于div内部,因此它正在执行按钮,然后向上链接到div。在按钮功能中添加event.stopPropagation()。

It's called 'bubbling'. The button is inside the div so it's executing button then up the chain to div. Add event.stopPropagation() inside the button function.

$("#"+comListID+"btn").click(function(event){
    event.stopPropagation();
    addNewArr(comListID);
});