简体   繁体   中英

Can you change a link title by named title attribute?

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:

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

当然,请使用属性选择器:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM