Answer the question
In order to leave comments, you need to log in
How to replace html code via Javascript?
how to shorten links in html code with JS?
For example, there is such a piece
<a href="http://site.site/uploads/posts/2009-01/1.gif" ><img src="/uploads/posts/2009-01/thumbs/1.gif" tooltip="Описание"></a>
<a href="/1.gif" ><img src="/1.gif" tooltip="Описание"></a>
Answer the question
In order to leave comments, you need to log in
I don't know what it makes sense, but if it's necessary, then:
<a id="site-link"> <img tooltip="Описание" id="site-photo"></a>
document.querySelector('#site-link').setAttribute('href', 'http://site.site/uploads/posts/2009-01/1.gif');
document.querySelector('#site-photo').setAttribute('src', '/uploads/posts/2009-01/thumbs/1.gif');
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question