假设我有 3 里。我想要做的是,当我单击任何 li 时,我想知道单击了哪个 li 并根据它添加一个事件。我如何使用 jquery 做到这一点,请提供任何帮助或建议
最佳答案
在 jQuery 中,在事件处理程序中,this 关键字指的是触发事件的元素。
$('li').click(function() {
alert($(this).text()); // read out the text of the list item that was clicked
}
关于javascript - 查找哪个li被点击,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3437998/