How to draw to an element inside another element?

Those. there is a list li, inside each li there is a, from which I need to know the href parameter. Whether I address through $ (this).

<script type="text/javascript"> $('document').ready(function () { $('.navtabs li').each(function () { if ('http://site/' + $(this).attr('href') == window.location.href) { $(this).addClass('selected'); } }); }); </script> 

or if, on the contrary, to set li referring through $ (this) to a?

    2 answers 2

    $ ("a", this) .attr ("href"); this is if you refer to the link via li (if this is li)

    And vice versa (if this is a link) $ (this) .parent () - this will be LI - the parent of the link.

      $ (this) .children ('a'), if you need to look for a direct descendant or $ (this) .find ('a'), for a more "wide" search.