I have an array of markup-strings like e.g.
const array = [
'<p class="item">text</p>',
'<h1>hello</h1>',
];
I want to replace the text-content of each markup-string's first tag. I thought of using the replace
method but since it's not always a <p>
tag and sometimes a tag's markup features a class-attribute, I can't rely on just targeting the text between <p>
and </p>
. I tried to use jQuery's html
method but it's not working.
How could one achieve the just described task?