I have this string HTML. it can have many href attributes.
"<h4> TITLE </h4> <p>test</p>
<a\r\n class=\"link\"\r\n target=\"_blank\" \r\n href=\"https://test.com\">\r\n LABEL HERE </a>.\r\n </p>\r\n
<a\r\n class=\"link\"\r\n \r\n href=\"https://test2.com\">\r\n LABEL HERE 2 </a>.\r\n </p>\r\n"
I need to loop to every a href and modify it and return it to something like this below: add text in the label. and add target="_blank" in the href attribute if it's not there yet. Would really appreciate the help. tried many things but couldn't get this to work.
"<h4> TITLE </h4> <p>test</p>
<a\r\n class=\"link\"\r\n \r\n target=\"_blank\" href=\"https://test.com\">\r\n LABEL HERE (ADD TEXT HERE)</a>.\r\n </p>
<a\r\n class=\"link\"\r\n \r\n target=\"_blank\" href=\"https://test2.com\">\r\n LABEL HERE2 (ADD TEXT HERE)</a>.\r\n </p>"
EDIT: tried this code but im getting the "expression is not callable, string has no call signatures" in the el.innerHTML code.
let consentDataxString: string = dataFromApi?.selectedData.toString() || '';
let el = document.createElement( 'html' )
el.innerHTML(consentDataxString)