鼠标悬停父级 = find() 子级 ID 名称
当鼠标悬停在#divlayer
上时,find()
id of child span
HTML:
<div id="divlayer">
<p>title</p>
<span id="apple">apple</span>
<span id="orange">orange</span>
<span id="kiwi">kiwi</span>
</div>
jQuery:
$('span').hide();
$('#divlayer').mouseover(function(){
$('span').show();
$(this).find(???).attr('id');
});
edit: my bad,我应该澄清我的问题。当鼠标指针移到
title
上时,span
子项被隐藏,每个的 id span
孩子被返回。
基本上,
title
when mouseover #divlayer
, find()
id of child span
HTML:
<div id="divlayer">
<p>title</p>
<span id="apple">apple</span>
<span id="orange">orange</span>
<span id="kiwi">kiwi</span>
</div>
jQuery:
$('span').hide();
$('#divlayer').mouseover(function(){
$('span').show();
$(this).find(???).attr('id');
});
edit: my bad, I should have clarified my question. the span
children are hidden, when the mouse pointer goes over <p>title</p>
, id of each span
child is returned.
Basically, <p>title</p>
is visible at first, and when the mouse goes over the it, children are shown and ids are returned individually.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
也许像这样..(编辑以满足您最后的要求)
Maybe like this.. (Edited to meet your last requirements)
根据您的更新
Based on your update
HTML:
jQuery:
给你了。它获取所有 id 并将其推入累加器。然后你可以用这些 id 做任何你需要的事情
HTML:
jQuery:
here you have it. it takes all id's and pushes it onto accumulator. then you can do whatever you need with these id's