search

Home  >  Q&A  >  body text

Remove closing slash '/' from image tag in XHTML

I have a string txt1 that stores an image. Its value is in XHTML format, that is, the element is closed: Happyface. But I need to remove that closing slash so it can be Happyface just like in HTML5.

Is there a way to do this.

P粉520545753P粉520545753453 days ago621

reply all(1)I'll reply

  • P粉447002127

    P粉4470021272023-09-07 10:26:00

    const txt1 = '<img src="happy.gif" alt="Happy face" />'.replace('/>', '>');
    console.log(txt1)

    reply
    0
  • Cancelreply