jquery上的事件?
当我单击element.conversation\u item>span jquery时,conversation\u item和conversation\u item>span都处于活动状态。我不想要它,但我必须在事件中使用。帮助我。您需要在单击事件时使用jquery上的事件?,jquery,events,Jquery,Events,当我单击element.conversation\u item>span jquery时,conversation\u item和conversation\u item>span都处于活动状态。我不想要它,但我必须在事件中使用。帮助我。您需要在单击事件时使用 $('body').on('click', '.conversation_item', function (e) { e.preventDefault(); console.log("go"); }); $('body')
$('body').on('click', '.conversation_item', function (e) {
e.preventDefault();
console.log("go");
});
$('body').on('click', '.conversation_item > span', function () {
console.log("true");
});
您需要停止以单击子元素:
$('body').on('click', '.conversation_item > span', function (e) {
e.stopPropagation()
alert("true");
});
您应该停止事件传播。看看这个
@skd很高兴帮助您:)
$('body').on('click', '.conversation_item > span', function (event) {
event.stopPropagation();
console.log("true");
});