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

Php 从链接中获取值并将其用于标题属性,php,css,drupal,Php,Css,Drupal,如何从链接中获取值 并将其用于title属性 发件人: 致: 我使用drupal作为CMS 我使用css内容属性来显示标题。 如果内容有一个value属性,那么它会容易得多 谢谢 这是我的导航代码: <nav id="main_menu"> <?php print theme('links__system_main_menu', array('links' => $main_menu, 'attributes' => array(

如何从链接中获取值 并将其用于title属性 发件人:


致:


我使用drupal作为CMS

我使用css内容属性来显示标题。 如果内容有一个value属性,那么它会容易得多

谢谢

这是我的导航代码:

<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 -->

如果
元素具有ID,则可以执行以下操作:

value = document.getElementById("ahrefid").innerHTML;
像这样试试

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

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

<a id="anchorId" href="#">Test</a>
var anchorVal = document.getElementById("anchorId").innerHTML;
document.getElementById("anchorId").setAttribute("title", anchorVal)

所有菜单项都需要将其值作为标题。您能告诉我如何将其实现到drupal主菜单吗?要将该值指定给标题,只需执行document.getElementById(“ahrefid”).setAttribute(“title”,value);我不知道drupal的具体细节。它按照我想要的方式工作,但它会将所有a的值粘贴到每个a中
<a id="anchorId" href="#">Test</a>
var anchorVal = document.getElementById("anchorId").innerHTML;
document.getElementById("anchorId").setAttribute("title", anchorVal)