从链接获取价值并将其用于标题属性

How do i get the value from a link and use it for the title attribute from:

<a href="#">Test</a>

to:

<a href="#" title="Test"></a>

I use drupal as CMS

I use the css content property to display the title. It would b so much easier if there was a value property for content.

Thanks

This is my navigation code:

<nav id="main_menu">


            <?php print theme('links__system_main_menu', array('links' => $main_menu, 'attributes' => array('class' => array('links', 'inline', 'clearfix')))); ?>
          </nav><!-- /#main_menu -->

Try like this

$(document).ready(function() {
    $value = $('a').text();
    $('a').attr('title', $value);
});

EDIT :

jQuery(document).ready(function($) {
 $('a').each(function() {
    $value = $(this).text();
    $(this).attr('title', $value);
 }) 
});

If the <a> element had an ID you could do:

value = document.getElementById("ahrefid").innerHTML;

HTML:

<a id="anchorId" href="#">Test</a>

Javascript:

var anchorVal = document.getElementById("anchorId").innerHTML;
document.getElementById("anchorId").setAttribute("title", anchorVal)

SEE DEMO