i have a string txt1 that store an image its value is in xhtml i.e the element is closed
<img src="happy.gif" alt="Happy face" />
but i need to remove that closure slash / so it can be <img src="happy.gif" alt="Happy face" >
as in html5
const txt1 = '<img src="happy.gif" alt="Happy face" />';
there is a way to convert it ?
CodePudding user response:
const txt1 = '<img src="happy.gif" alt="Happy face" />'.replace('/>', '>');
console.log(txt1)