I have the following html structure:
<div class="event tiny">
<a href="/whatever">Something</a>
</div>
And I want to replace the text of this link with “Anything” …
When doing this …
$('.event a').replaceWith("Anything");
… the text is replaced but also the link is gone.
When doing this …
$('.event a').text().replaceWith("Anything");
… nothing happens.
Like this, if the new text is all the same.
jQuery loops over the
aelements, and replaces its content with the"Anything"text.