Onclick on image I need to change the background of li using jquery
LI is not immediate parent so I am not able to use parent() function in jquery
<li class="ui-widget-content ui-corner-tr ui-draggable">
<fb:profile-pic height="32" width="32" linked="false" uid="557103888" style="width: 32px; height: 32px;" class=" fb_profile_pic_rendered">
<img class="" style="width: 32px; height: 32px;" title="some name" alt="some name" src="files/t557103228_5135.jpg">
</fb:profile-pic>
</li>
Use
.closest('li').This will give you the first ancestor of the
<img>that is an<li>element.You could also use
.parents('li:first'). It uses the:firstselector to ensure you only get the first result.