This code worked for me: $("#mainCol ul li a").each(function() { var headerText = $(this).parent().siblings("h1").text(); $(this).attr("title", headerText ); });
Also, you might want to consider using something other than an <h1> tag. Strictly speaking, that tag is supposed to represent the document's header, rather than the header of an individual element. I'd recommend using a <div> or <span> tag instead. David On Mar 6, 11:32 am, Joe <[EMAIL PROTECTED]> wrote: > So I'm having an issue attempting to traverse back in a <li> element > to grab the text inside a header tag and insert that text as the > "title" attribute's value in a link. The markup will more more sense: > > <div id="mainCol"> > <ul> > <li> > <h1>Header 1</h1> > <p>Some nice text here.</p> > <p><a href="url" title="">Click Here!</a></p> > </li> > <li> > <h1>Header 2</h1> > <p>Some nice text here.</p> > <p><a href="url"></a></p> > </li> > > </ul> > </div> <!-- End of Main Column --> > > $(document).ready(function(){ > > // Add title to each link in the main content column's unordered list > for each list element by using the h1 tag's text. > > $('#mainCol ul li a').each(function(){ > // Grab the header text of this link's header parent > $(this).parents().size()); > }); > > }); // End of ready function. > > Clearly this script won't execute what I need, but the size is 0 and I > can't seem to traverse up the DOM to grab the <h1> tag's text with > combinations using parent, parents, siblings, etc.. Any suggestions?