)|(<\/?span.*?>)/g, ' ');" method can remove the a tag."/> )|(<\/?span.*?>)/g, ' ');" method can remove the a tag.">

Home  >  Article  >  Web Front-end  >  How to remove a tag in javascript

How to remove a tag in javascript

藏色散人
藏色散人Original
2021-06-27 10:45:463169browse

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.

How to remove a tag in javascript

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

<a href="http://git.oschina.net/" style="box-sizing: border-box; color: rgb(51, 51, 51); text-decoration: none; transition: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1); -webkit-transition: all 0.5s cubic-bezier(0.175, 0.885, 0.32, 1); max-width: 100%; transparent;"><span data-wiz-span="data-wiz-span" style="box-sizing: border-box; max-width: 100%; font-size: 14pt;">http://git.oschina.net</span></a>

Implementation method:

(<\/?a.*?>)|(<\/?span.*?>)

That is:

str.replace(/(<\/?a.*?>)|(<\/?span.*?>)/g, '');

Running results

How to remove a tag in javascript

##[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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn