Delete items using "display: none"; for email using javascript

I create email from a web page and take part of the page and put it in email. The problem is that there are elements in the code section with "display: none"; and some email clients do not recognize the display: none property, which then displays unwanted elements in the message.

I want to remove these elements using simple javascript which already removes elements with specific classes. Now I want to remove elements with certain styles, the styles are inline. I am using jquery with the site.

+4
source share
2 answers

Use the selector :hidden :

 $(":hidden").remove(); 
+6
source
  $("div[style*='display:none']").remove(); 
+1
source

Source: https://habr.com/ru/post/1299527/


All Articles