Reputation: 106
I'll illustrate with an example: I need to convert the following html with javascript
<a href="aaa.kmz"></a>
<a href="eee.kmz"></a>
<a href="rrr.kmz"></a>
...
to code where all href values has changed only the last letter
<a href="aaa.kml"></a>
<a href="eee.kml"></a>
<a href="rrr.kml"></a>
...
Upvotes: 0
Views: 249
Reputation: 35793
Get the a tags, loop through them and replace .kmz
with .kml
:
var tags = document.getElementsByTagName("a");
for(var i = 0, l = tags.length; i < l; i++) {
tags[i].href = tags[i].href.replace('.kmz', '.kml');
}
Working Example - http://jsfiddle.net/Ln4s4/
Upvotes: 4