e.stopPropagation() - 点击元素是传播还是原始?

时间:2011-08-15 11:55:34

标签: javascript jquery

如何检查元素是原始元素还是单击元素的传播?


修改

如果我这样做,'propagation'始终会收到警告:

this.row.click(function(e){
    if(e.target === this) alert('origin');
    else alert('propagation');

    //e.stopPropagation();
});

1 个答案:

答案 0 :(得分:2)

检查event.target [docs]

if(event.target === this) {
    // origin of the event
}