Thanks, but looks like I am making some newbie mistake where $(this) does not seem to be working. This is the function being called in onclick in <img> tag.
function showinfo(){ var desc =$(this).parents('td[title]:eq(0)').attr('title'); var show = '<div style="font-size:110%; padding-top:15px; width:auto;>' + '<span style="font-weight:bold;"> Description: </ span>' + desc +'</div>'; $.modal(show); } <tr> <td title="This is the description from db"> <img src="/site_media/ contract.png" onclick="showinfo();" alt="Case" title="Case" width="16" height="16"/> </td> </tr> I get desc = "undefined". if I do $(this). attr('title') I get undefined as well though img has a title attribute. do I need to tell jquery to provide $(this) to this function. On Nov 19, 3:17 pm, "Hector Virgen" <[EMAIL PROTECTED]> wrote: > If the image is clicked, you can then traverse up the dom to the parent td > with a title. > $(this).parents('td[title]:eq(0)').attr('title'); // returns the value of > the 'title' attribute > > -Hector > > On Wed, Nov 19, 2008 at 3:14 PM, Ashish <[EMAIL PROTECTED]> wrote: > > > <tr> > > <td title="This is the description from db"> > > <img src="/site_media/ > > contract.png" onclick="showinfo();" alt="Case" title="Case" width="16" > > height="16"/> > > </td> > > </tr> > > > What I want is when some one clicks on the image in showinfo() > > javascript function I can retrieve the value of "title" from the > > enclosing td tag. In this case the value returned should be "This > > is the description from db" > > > Please note that there are multiple rows with clickable images and > > each with different value of title from DB. So corresponding value of > > title should be returned.