Widget:ToggleWidth: Difference between revisions

From The Midnight Wiki
No edit summary
No edit summary
Line 1: Line 1:
<html>
<html>
<head>
<style>
#myDIV {
  width: 100%;
  padding: 50px 0;
  text-align: center;
  background-color: lightblue;
  margin-top: 20px;
}
</style>
</head>
<body>
<body>
<p>Click the "Try it" button to toggle between hiding and showing the DIV element:</p>
<button onclick="myFunction()">Try it</button>
<button onclick="myFunction()">Try it</button>
<div id="myDIV">
This is my DIV element.
</div>
<p><b>Note:</b> The element will not take up any space when the display property set to "none".</p>
<script>
<script>
function myFunction() {
function myFunction() {
   var x = document.getElementById("myDIV");
   var x = document.getElementsByClassName("ts-inner");
   if (x.style.display === "none") {
   if (x.style.maxWidth === "none") {
     x.style.display = "block";
     x.style.maxWidth = "115em !important";
   } else {
   } else {
     x.style.display = "none";
     x.style.maxWidth = "none !important";
   }
   }
}
}
</script>
</script>
</body>
</body>
</html>
</html>

Revision as of 13:21, 5 July 2023

<html> <body> <button onclick="myFunction()">Try it</button> <script> function myFunction() {

 var x = document.getElementsByClassName("ts-inner");
 if (x.style.maxWidth === "none") {
   x.style.maxWidth = "115em !important";
 } else {
   x.style.maxWidth = "none !important";
 }

} </script> </body> </html>