skip to Main Content

How to replace <li> tag in HTML with another tag and place it value in the new tag

I need to update the following HTML to wrap each <li> with <li><li-text>{li value}</li-text> <ul><li>one</li><li>two<ul><li>three<ul><li>four<ul><li>five</li></ul></li></ul></li></ul></li></ul> hints: I ONLY USING JS, NO JQUERY I'm trying this, but it's not working as expected! var html = `<ul><li>one</li><li>two<ul><li>three<ul><li>four<ul><li>five</li></ul></li></ul></li></ul></li></ul>`.replace(/<li[^>]*>/g,'<li><li-text>$&</li-text>') The result I'm getting is…

VIEW QUESTION
Back To Top
Search