An Interest In:
Web News this Week
- April 26, 2024
- April 25, 2024
- April 24, 2024
- April 23, 2024
- April 22, 2024
- April 21, 2024
- April 20, 2024
September 24, 2021 06:02 pm GMT
Original Link: https://dev.to/tanwi2209/how-to-remove-css-property-using-javascript-2pjk
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 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:
2.) After Click the button remove property call and removes the previous css property of text:
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
Original Link: https://dev.to/tanwi2209/how-to-remove-css-property-using-javascript-2pjk
Share this article:
Tweet
View Full Article
Dev To
An online community for sharing and discovering great ideas, having debates, and making friendsMore About this Source Visit Dev To