How to get the Name attribute of an anchor tag

Here is my html markup (cut down)

<li class="tab"><a href="#" name="content1">Tab 1</a></li>
<li class="tab"><a href="#" name="content2">Tab 1</a></li>
<li class="tab"><a href="#" name="content3">Tab 1</a></li>

All I want to do is get the name attribute of the <a> tag when its parent <li> is clicked, as such:

$('li.tab').bind('click', function (e) {
  var contentRequested = $(this + " a").name; // <-- this is not working to get the Name attribute
  alert(contentRequested)
  e.preventDefault;
});

How do I use $(this) and then find the <a> tag within it and finally get the name attribute value?


solution

Something like $(this).find('a').attr('name'); would work:

EXAMPLE HERE

$('li.tab').click(function(){
  console.log($(this).find('a').attr('name'));
});