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'));
});
});