javascript - get string in tag
为情所困
为情所困 2017-07-05 10:43:32
0
5
849


The picture shown is an html string. Is there any way to get the content in the red box?

为情所困
为情所困

reply all(5)
滿天的星座
var dom = $('a').clone();
        dom.find('i,button').remove();
        console.log(dom.html());
Peter_Zhu

Provide an idea to use regular expressions to match tag segments...

小葫芦

First get the dom of the a tag
Then find the node whose nodeName is '#text' from the a.childNodes array and get the nodeValue.

世界只因有你

You can refer to my answer to this question, the idea is the same:
/q/10...

Also attached is a method to convert code strings into DOM:
https://stackoverflow.com/que...

var code = '<li>text</li>';
var p = document.createElement('p');
p.innerHTML = code;

var elements = p.childNodes;
三叔

If it can be converted into a DOM object, use javascript; if it can only use strings, use regular matching.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template