The picture shown is an html string. Is there any way to get the content in the red box?
滿天的星座2017-07-05 10:45:32
var dom = $('a').clone();
dom.find('i,button').remove();
console.log(dom.html());
高洛峰2017-07-05 10:45:32
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.
世界只因有你2017-07-05 10:45:32
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;
三叔2017-07-05 10:45:32
If it can be converted into a DOM object, use javascript; if it can only use strings, use regular matching.