Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

remove elements with "display: none;" for email using javascript

I'm generating a email from a web page and taking a section of the page and putting it into the email. The problem is the section of code has elements with "display: none;" and some email clients don't recognise the display:none property which then displays unwanted elements in the email.

I want to remove these elements using some simple javascript i already remove elements with certain classes now i want to remove elements with certain styles, the styles are inline. I'm using jquery with the site.

like image 943
Nic Avatar asked Jan 27 '10 10:01

Nic


People also ask

Does display none remove element from Dom?

display:none removes the element from the document. It does not take up any space.

Can we hide HTML elements using JavaScript?

Style display property is used to hide and show the content of HTML DOM by accessing the DOM element using JavaScript/jQuery. To hide an element, set the style display property to “none”. document.

How do you hide things in JavaScript?

# How to hide elements completely Completely hiding elements can be done in 3 ways: via the CSS property display , e.g. display: none; via the CSS property visibility , e.g. visibility: hidden; via the HTML5 attribute hidden , e.g. <span hidden>

What is .remove in JavaScript?

The remove() method removes an element (or node) from the document.


1 Answers

Use the :hidden selector:

$(":hidden").remove();
like image 95
cletus Avatar answered Nov 13 '22 15:11

cletus