Has anyone now how to simplify the following expression by avoiding using attr("id")
alert($("#"+$(obj).attr("id")+"~p:last").attr("id")); I need this because not every image could have an id. <script language="javascript" type="text/javascript"> function ExpandCollapseOnLeftPanel(obj) { if ($(obj).attr("src") == "/Content/Images/arrow_bot.gif") { // expand $(obj).attr("src", "/Content/Images/arrow_side.gif"); $("#" + $(obj).attr("id") + "~p:last").css("display", "block"); } else //collapse { $(obj).attr("src", "/Content/Images/arrow_bot.gif"); $("#" + $(obj).attr("id") + "~p:last").css("display", "none"); } } </script> <div class="blok"> <img id="iTA" src="/Content/Images/arrow_bot.gif" alt=" " class="l_ar" onclick="ExpandCollapseOnLeftPanel(this)" /> <p id="p1"> Tracking activities </p> <p style="display:none"> <a href="#">home</a><br /> movie...@lucy,@Bob(3)<br /> @Canlis table for 2 at ..(1)<br /> </p> </div>