)|(<\/?span.*?>)/g, ' ');" method can remove the a tag.">
How to remove the a tag in javascript: first find the corresponding js code part; then pass "str.replace(/()|()/g, '') ;" method can remove the a tag.
The operating environment of this article: windows7 system, javascript version 1.8.5, Dell G3 computer.
How to remove the a tag in javascript?
Specific question:
js to remove the a tag and leave the content
How to use regular rules to remove the a tag and leave only the content http:/ /git.oschina.net
The way to replace the a tag part with empty is not to directly take the content of the a tag, because there are a lot of such codes, and there are other codes that need to be left in place
http://git.oschina.net
Implementation method:
(<\/?a.*?>)|(<\/?span.*?>)
That is:
str.replace(/(<\/?a.*?>)|(<\/?span.*?>)/g, '');
Running results
##[Recommended learning:javascript advanced tutorial】
The above is the detailed content of How to remove a tag in javascript. For more information, please follow other related articles on the PHP Chinese website!