Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/37.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/vba/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
jQuery按类选择并在ASP.NET中将当前元素作为参数传递_Asp.net_Jquery_Mouseover_Parameter Passing - Fatal编程技术网

jQuery按类选择并在ASP.NET中将当前元素作为参数传递

jQuery按类选择并在ASP.NET中将当前元素作为参数传递,asp.net,jquery,mouseover,parameter-passing,Asp.net,Jquery,Mouseover,Parameter Passing,这是我的密码: $(document).ready(function(){ $('.classOne').mouseover(function(e) { alert($(e).attr('id')); }); }); 现在,我知道我的代码实际上有问题,为了得到我在alert()消息中悬停的当前asp:LinkButton的ID的结果,什么是正确的? 谢谢大家的帮助 您应该这样做: $(document).ready(function(){

这是我的密码:

$(document).ready(function(){  
    $('.classOne').mouseover(function(e) {  
        alert($(e).attr('id'));  
    });  
});  
现在,我知道我的代码实际上有问题,为了得到我在
alert()
消息中悬停的当前
asp:LinkButton
的ID的结果,什么是正确的?

谢谢大家的帮助

您应该这样做:

$(document).ready(function(){
   $('.classOne').mouseover(function() {
      alert($(this).attr('id'));
   });
});

您应该这样做:

$(document).ready(function(){
   $('.classOne').mouseover(function() {
      alert($(this).attr('id'));
   });
});

e是你的事件,不是你的元素。您的元素被包装在此函数中


$(document).ready(function() {
    $('.classOne').mouseover(function(e) {
        alert($(this).attr('id'));
    });
});

e是你的事件,不是你的元素。您的元素被包装在此函数中


$(document).ready(function() {
    $('.classOne').mouseover(function(e) {
        alert($(this).attr('id'));
    });
});
两个假设:

  • 链接按钮使用有效类“classOne”呈现
  • 该按钮不会通过AJAX回调添加到页面集合中
  • “e”参数实际上是事件的对象&而不是HTML元素的对象

    (文档).ready(函数(){
    $('.classOne').bind('mouseover',function(){
    警报($(this.attr('id'));
    });
    });

两个假设:

  • 链接按钮使用有效类“classOne”呈现
  • 该按钮不会通过AJAX回调添加到页面集合中
  • “e”参数实际上是事件的对象&而不是HTML元素的对象

    (文档).ready(函数(){
    $('.classOne').bind('mouseover',function(){
    警报($(this.attr('id'));
    });
    });