[英]jquery hover() not firing
我有一个带有以下标记的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...');
}
}
也许是因为t1的HTML在脚本标签中? 还是jQuery模板是如何工作的?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.