使用 mootools 选择器访问元素属性
我试图将鼠标悬停事件附加到页面中图库的所有 img 元素(使用 Mootools)。使用类似
$$('img.mygalleryclass').addEvents({
mouseover: function(){
alert(id);
}
});
我的问题是,如何提醒 $$ '循环' 中引用的元素的 id?由于未定义 id,“alert(id)”每次都会返回错误。
谢谢!
I'm trying to attach a mouseover event to all img elements of a gallery in a page (using Mootools). This is easy enough using something like
$('img.mygalleryclass').addEvents({
mouseover: function(){
alert(id);
}
});
My question is, how do I alert the id of the element referenced in the $$ 'loop'? That "alert(id)" returns an error every time since id is not defined.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
将
event
参数传递给mouseover
函数,然后获取target
的id
:这是一个示例。
Pass the
event
argument to themouseover
function and then get theid
of thetarget
:Here's an example.