我有一个带有以下标记的 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/