I would like to change the text of the HTML element, but save the rest of the internal html using jQuery.
For example:
<a href="link.html">Some text <img src="image.jpg" /></a>
replace "Some text" with "Other text", and the result should look like this:
<a href="link.html">Other text <img src="image.jpg" /></a>
EDIT: My current solution is as follows:
var aElem = $('a'); var children = aElem.children(); aElem.text("NEW TEXT"); aElem.append(children);
But there must be an even more elegant way to do this.
jquery
Drejc Mar 08 2018-11-11T00: 00Z
source share