您可以通过命名标题属性更改链接标题吗?

时间:2022-11-23 11:32:25

I'm trying to figure out if it's possible (and if so how) to change a link's color by polling the title attribute. I'm working with an HTML page that is generated from another script that creates a accordion list of hyperlinks. A couple of those hyperlinks I'd like to highlight, and I believe I can shoehorn in some JavaScript to do this (and the title attribute is the only unique element I can rely on), but I'm not sure how to write it. Here's what a bit of the list page looks like:

我试图弄清楚是否有可能(如果是这样)通过轮询title属性来改变链接的颜色。我正在使用从另一个脚本生成的HTML页面,该脚本创建一个手风琴超链接列表。我想强调的几个超链接,我相信我可以用一些JavaScript来做这个(并且title属性是我唯一可以依赖的独特元素),但我不知道如何写它。这是列表页面的一点:

<div class="AccordionPanel AccordionPanelOpen">
    <div class="AccordionPanelTab">
    Forms
    </div>
        <div class="AccordionPanelContent" style="height: auto; display: block;">
            <ul class="arrows searchSubtype">
               <li class=""> 
                  <a title="Form-1.doc" target="_top" href="../Form-1.doc">
                  Form 1
                  </a>
               </li>
               <li class=""> 
                  <a title="Form-2.doc" target="_top" href="../Form-2.doc">
                  Form 2
                  </a>
               </li>
               <li class=""> 
                  <a title="Form-3.doc" target="_top" href="../Form-3.doc">
                  Form 3
                  </a>
               </li>
               <li class=""> 
                  <a title="Form-4.docx" target="_top" href="../Form-4.docx">
                  Form 4
                  </a>
               </li>
            </ul>
    </div>
</div>

1 个解决方案

#1


2  

Sure, use the attribute selector:

当然,使用属性选择器:

$("a[title='Form-4.docx']").css("color","red");

#1


2  

Sure, use the attribute selector:

当然,使用属性选择器:

$("a[title='Form-4.docx']").css("color","red");