How to add “name” attribute to a links in sidebar

I need to add “name” attribute to all links in the sidebar.
For example;

Before

Read More
<li id="menu-item-573" class="gallery-menu-top menu-item menu-item-type-custom menu-item-object-custom menu-item-573"><a href="#">WEDDINGS</a></li>

After

<li id="menu-item-573" class="gallery-menu-top menu-item menu-item-type-custom menu-item-object-custom menu-item-573"><a name="Weddings" href="#">WEDDINGS</a></li>

name=”Weddings”

Related posts

Leave a Reply

1 comment

  1. If you can add this class to the side menu UL “sidebar”;
    and the value of the name attribute is always going to match the content of the link then this should work:

     $('.sidebar a').each(function(i, item){   
         var value = item.textContent;        
          $(item).attr('name', value );            
      });
    

    Here’s a working example = http://jsfiddle.net/4SNv4/

    EDIT sorry just noticed this is a word press question: so you probably dont have the ability to do the above.