gpt4 book ai didi

javascript - jquery hover() 不触发

转载 作者:行者123 更新时间:2023-11-30 13:36:13 25 4
gpt4 key购买 nike

我有一个带有以下标记的 ASP.NET 用户控件:

<div>
<script id="myTemplate" type="text/x-jquery-tmpl">
<table id="t1"><tr>...<td class="myclass"><span>First Name:</span></td>...<\tr> <\table>
</script>

<table id="t2"><tr>...<td class="myclass"><span>First Name:</span></td>...<\tr> <\table>
<\div>

我想为所有具有 class="myClass"的类触发 hover()。我已经放置了以下代码:

$(document).ready(function() {
$(".myClass").hover(
function() {
alert('in...');
},
function() {
alert('out...');
});
}

问题是 .hover() 会触发表“t2”中的 td 元素,但不会触发“t1”。有人可以帮忙吗?

最佳答案

.hover 静态添加事件处理程序。

尝试做

$(".myClass").live("hover",
function() {
alert('in...');alert('out...');
}
}

关于javascript - jquery hover() 不触发,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4748737/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com