使用jquery提取标记和添加标题属性之间的值

使用jquery提取标记和添加标题属性之间的值,jquery,siebel,extract-value,Jquery,Siebel,Extract Value,我在动态生成的页面上有几个a标记,如下所示 <a href='JavaScript:SWETargetGotoURL(vtUrl+"XRX+eCustomer+Account+Inventory+View", "_self")' id='s_ViewBar' name=s_ViewBar>&nbsp;Inventory&nbsp;</a> a标记最终应该是这样的 <a href='JavaScript:SWETargetGotoURL(vtUrl

我在动态生成的页面上有几个a标记,如下所示

<a href='JavaScript:SWETargetGotoURL(vtUrl+"XRX+eCustomer+Account+Inventory+View", "_self")'  id='s_ViewBar' name=s_ViewBar>&nbsp;Inventory&nbsp;</a>
a标记最终应该是这样的

<a href='JavaScript:SWETargetGotoURL(vtUrl+"XRX+eCustomer+Account+Inventory+View", "_self")'  title = "This is inventory homepage" id='s_ViewBar' name=s_ViewBar>&nbsp;Inventory&nbsp;</a>

非常感谢您的帮助。

我想您需要的是在所选元素集上迭代的元素

$('a[href*="SWETargetGotoURL"]').each(function () {

    //get the text of the element
    var extractedtext = $(this).text();

    //check text for match
    if (extractedtext == "&nbsp;Inventory&nbsp;") {

        //Change title attribute of element
        $(this).attr('title', "This is inventory homepage");
    }
});
 var screenName = $('a[href*="SWETargetGotoURL"]').attr('href');
$('a[href*="SWETargetGotoURL"]').each(function () {

    //get the text of the element
    var extractedtext = $(this).text();

    //check text for match
    if (extractedtext == "&nbsp;Inventory&nbsp;") {

        //Change title attribute of element
        $(this).attr('title', "This is inventory homepage");
    }
});