【发布时间】:2010-01-07 20:36:50
【问题描述】:
我有一个像这样的带有 img 的 h4。我将点击功能绑定到 h4。这很好用。但我无法选择其中的 img。我想选择 img 以便用 .attr("src").replace("up", "down"); 替换 src attr .
<h4 class="collapsable_head">
<img id="up_down" class="icon" src="/crm/img/modifier_down.gif" alt="link"/>
<b>Classification Filter:</b>
</h4>
javascript:
$(".collapsable_head").click(function(){
$(this).next(".collapsable_body").slideToggle(500)
//None of the next lines return me the img object
src = jQuery(this).children('img').attr("src");
print(src);
src = $(this).next("#up_down").attr("src");
print(src);
src = $(this).next("#up_down").attr("src");
print(src);
return false;
});
我想使用关键字“this”,因为我还有更多(“.collapsable_head”);-)
【问题讨论】: