不确定为什么以下代码未能运行。如果我将 .on()
更改为 .live()
,它就能工作,但是 live 事件会一直存在,并且由于这是一个会在页面上多次出现和消失的东西,每次单击时 live 将继续添加到事件行中。我想简短明了地说,为什么它不起作用呢?
$("#" + old_n).on('mousedown', function(evt) {
console.log(old_n);
if($(el).data('clickphase')) {
return true;
}
$("#" + $.contextmenu).remove();
$(el).data('served', true);
if(typeof array_of_a[a_index][1] == 'function') {
array_of_a[a_index][1](evt, el);
}
// console.log(array_of_a[a_index]);
// array_of_a[a_index][1](evt, el);
$(el).removeData('served');
});
old_n
是当前被点击的 <li>
的 id,该元素还有一个 hover
事件。但这不应该影响到鼠标按下事件,对吧?