Jump to content

Search all anchors and then edit their cotent


Ollifi

Recommended Posts

Hello. how could I search all anchors

<a name="****A****">****B****</a>

And then edit the text part B.

 

Example, this

<a name="1202">Hello!</a>

would replace

<a name="1202">Hello! <small>ID#1202</small></a>

 

This is coming a greasemonkey script. Hopefully you can help.

thank you very much.

 

EDIT:

I coded this: (bookmarklet test)

javascript:function(){for(i=0;i<document.links.length;i++){if(document.links[i].name){document.links[i].innerHTML = "Test "+document.links[i].name+"";}};}();

but it didn´t work.

I got it fixed:

javascript:(function () {var anchors = document.getElementsByTagName('a');var length = anchors.length;for (i=0; i<length; i++){if(anchors[i].name){var vanha=anchors[i].innerHTML;anchors[i].innerHTML=""+vanha+" <span style='font-size:10px;color:black'><a href='javascript:prompt(\"URL:\", \""+location.href+"~no.paging#"+anchors[i].name+"\");'>ID</a></span>";}}})();

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.