Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
185
rated 0 times [  189] [ 4]  / answers: 1 / hits: 63041  / 8 Years ago, wed, november 2, 2016, 12:00:00

How can I remove the background-color and opacity property using Javascript only (no Jquery!).



I tried this:



document.getElementById('darkOverlay').style.removeProperty(background-color);
document.getElementById('darkOverlay').style.removeProperty(opacity);


but it did not work.


More From » html

 Answers
56

You can just reset properties by either setting them to an empty string:



document.getElementById('darkOverlay').style.backgroundColor = ;
document.getElementById('darkOverlay').style.opacity = ;


Or setting them to the default values you like:



document.getElementById('darkOverlay').style.backgroundColor = transparent;
document.getElementById('darkOverlay').style.opacity = 1;

[#60209] Monday, October 31, 2016, 8 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
dexter

Total Points: 717
Total Questions: 98
Total Answers: 115

Location: Sudan
Member since Thu, May 7, 2020
4 Years ago
;