Inserisce uno style alla DIV dinamicamente




https://www.w3schools.com/howto/tryit.asp?filename=tryhow_js_toggle_class


<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<style>
.mystyle {
width: 100%;
padding: 25px;
background-color: coral;
color: white;
font-size: 25px;
box-sizing: border-box;
}
</style>
</head>
<body>

<p>Click the "Try it" button to toggle between adding and removing the "mystyle" class name of the DIV element:</p>

<button onclick="myFunction()">Try it</button>

<div id="myDIV">
This is a DIV element.
</div>

<script>
function myFunction() {
var element = document.getElementById("myDIV");
element.classList.toggle("mystyle");
}
</script>

</body>
</html>











( inserisceunostylealladivdinamicamente.html )- by Paolo Puglisi - Modifica del 17/12/2023