• Welcome to the eight year blog, I'm glad to meet you at the right age!
  • Due to the theme, QQ login partners will display the default avatar in the comments. Please go to the personal center and upload the avatar again.

JS matches the style in HTML tags

Code Notes barben 2 months ago (10-09) 142 views 0 comments

There is a news content module in the project, which is HTML text from the back end. I decided to render it with v-html in the front end.

 A piece of HTML content from the back end

However, rendering the style tag directly on this page is really ridiculous!

 Regular match style in HTML tag and clear

Use the regular replace tag in the style to delete the tag

 Content = content = content.replace (/ style / s * = / s * = / s * = / s * "/ Ig,") / Ig, "); 
 / / or you can, you can first remove the double quotes, and then remove the single quotes, / / content = content. Replace (/ style = / style =" / "/ Ig,") / Ig, ") / Ig,");;; "/ / or you can, you can first remove the double quotes, and then remove the single quotes, / / content = content. Content. Replace (/ style = / style =" / style = "/" / "/ Ig,") / Ig, ") / Ig,") / Ig, "/ Ig,");;;; "/ / or you can, you can first remove the double quotation marks, and then remove the single quotation marks / / content = content = content = content.replace (replace (/ style = '[^ \'] *? '/ Ig,");

 


Eight blogs that year, we've been there all the time
If the author does not indicate the original article, please indicate the link and source of this article
JS matches the style - https://www.barben.cn/code/907.html in the HTML tag
Like it( ten )
Post my comments
Cancel comment
expression Mapping Bold Strikethrough Center Italics

You need to bring your nickname and email with you in the year of eight!

  • Nickname (required)
  • Email address (required)
  • website