【发布时间】:2012-01-15 15:38:29
【问题描述】:
我有一堆具有相同类的项目,当它们被选中时会打开一个工具提示和下拉菜单。它适用于单个项目,但为了让每个项目都与它的特定子项目一起工作,我使用了 .children()。它似乎在某些地方有效,但在其他地方无效。我已经缩小了不起作用的范围,但对原因一无所知...请帮助。
HTML:
<div class="topIcon">
<a href="stream.html"><img src="icons/stream16lg.png" /></a>
<div class="topIconNew"></div>
<div class="topTip">
<div class="topTipText">Stream</div>
</div>
<div class="topDrop">Hello</div>
</div>
jQuery:
$("div.topIconNew").click(function(){
//working
$(this).parent("div.topIcon, div#topSend, div#topTool").css("background-color","#555555");
//working
$(this).children("div.topTip").show();
//not working
$(this).children("div.topTip").animate({width:320,marginLeft:-240},"fast");
//not working
$(this).children("div.topDrop").slideDown(240);
clicked = true;
});
我没有包含 CSS,因为我不确定这真的是问题所在。我认为这是我的 jQuery,但我真的不知道。感谢您提供任何和所有帮助。
【问题讨论】:
-
+1 为真棒标题
-
“我很难让 .children() 工作。”嘿,童工法的存在是有原因的。
标签: jquery html class children