How to remove CSS Property using javascript?

<!DOCTYPE html>
<html>
<head>
<style>
#myDIV {
background-color: coral;
border: 1px solid;
padding: 50px;
color: white;
}
</style>
</head>
<body>

<div id=”myDIV”>This div element has an onmousem…


This content originally appeared on DEV Community and was authored by Tanwi Kumari

<!DOCTYPE html>
<html>
<head>
<style>
#myDIV {
  background-color: coral;
  border: 1px solid;
  padding: 50px;
  color: white;
}
</style>
</head>
<body>

<div id="myDIV">This div element has an onmousemove event handler that displays a random number every time you move your mouse inside this orange field.
  <p>Click the button to change the color of text.</p>
  <button onclick="removeHandler()" id="myBtn">Try it</button>
</div>

<h1 id="demo">Hello everyone</h1>

<script>
document.getElementById("myDIV").addEventListener("mousemove", myFunction);

function myFunction() {
  document.getElementById("demo").style.color = "green";
}

function removeHandler() {
  document.getElementById("demo").style.removeProperty('color');
}
</script>
</body>
</html>

OUTPUT:

1.) Without Click ‘Try It’ button text is ‘green’:

Screenshot (325)

2.) After Click the button remove property call and removes the previous css property of text:

Screenshot (326)

To learn from each other keep sharing and learning!
follow me on Twitter also I post my daily learning and work on Twitter.
https://twitter.com/tk22O9


This content originally appeared on DEV Community and was authored by Tanwi Kumari


Print Share Comment Cite Upload Translate Updates
APA

Tanwi Kumari | Sciencx (2021-09-24T18:02:57+00:00) How to remove CSS Property using javascript?. Retrieved from https://www.scien.cx/2021/09/24/how-to-remove-css-property-using-javascript/

MLA
" » How to remove CSS Property using javascript?." Tanwi Kumari | Sciencx - Friday September 24, 2021, https://www.scien.cx/2021/09/24/how-to-remove-css-property-using-javascript/
HARVARD
Tanwi Kumari | Sciencx Friday September 24, 2021 » How to remove CSS Property using javascript?., viewed ,<https://www.scien.cx/2021/09/24/how-to-remove-css-property-using-javascript/>
VANCOUVER
Tanwi Kumari | Sciencx - » How to remove CSS Property using javascript?. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2021/09/24/how-to-remove-css-property-using-javascript/
CHICAGO
" » How to remove CSS Property using javascript?." Tanwi Kumari | Sciencx - Accessed . https://www.scien.cx/2021/09/24/how-to-remove-css-property-using-javascript/
IEEE
" » How to remove CSS Property using javascript?." Tanwi Kumari | Sciencx [Online]. Available: https://www.scien.cx/2021/09/24/how-to-remove-css-property-using-javascript/. [Accessed: ]
rf:citation
» How to remove CSS Property using javascript? | Tanwi Kumari | Sciencx | https://www.scien.cx/2021/09/24/how-to-remove-css-property-using-javascript/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.