这是我的代码:
$(document).ready(function(){
$('.classOne').mouseover(function(e) {
alert($(e).attr('id'));
});
});
现在,我知道我的代码实际上有问题,为了获得asp:LinkButton
我悬停在alert()
消息中的当前 ID 的结果,什么是正确的?
感谢所有帮助者!
这是我的代码:
$(document).ready(function(){
$('.classOne').mouseover(function(e) {
alert($(e).attr('id'));
});
});
现在,我知道我的代码实际上有问题,为了获得asp:LinkButton
我悬停在alert()
消息中的当前 ID 的结果,什么是正确的?
感谢所有帮助者!
你应该这样做:
$(document).ready(function(){
$('.classOne').mouseover(function() {
alert($(this).attr('id'));
});
});
e 是您的事件,而不是您的元素。您的元素包含在此函数中。
$(document).ready(function() {
$('.classOne').mouseover(function(e) {
alert($(this).attr('id'));
});
});
几个假设:
'e' 参数实际上是事件的对象而不是 HTML 元素的对象
(document).ready(function(){
$('.classOne').bind('mouseover', function(){
alert($(this).attr('id'));
});
});