Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and the Yahoo Answers website is now in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

HTML (Top Answer Will Be Picked)?

I am looking for an html code to allow the visitor of my website to turn off or on a specific section of the HTML.

4 Answers

Relevance
  • 9 years ago
    Favorite Answer

    You can't do that in HTML.

    What you might want is JavaScript.

    Try entering the following into an HTML file, then run it in your favorite browser:

    <html>

    <head>

    <script type="text/javascript">

    var on = 1;

    function onOff()

    {

    var d = document.getElementById("d");

    if (on == 1) {

    d.style.display = "none";

    on = 0;

    } else {

    d.style.display = "inline";

    on = 1;

    }

    }

    </script>

    </head>

    <body>

    <div id="a">

    <h1>I'm always here</h1>

    <input type="button" value="On/Off" onclick="onOff()" />

    </div>

    <div id="d">

    <h1>I can go away</h1>

    </div>

    </body>

    </html>

  • 9 years ago

    Elaborate

  • 9 years ago

    Elaborate

  • Anonymous
    9 years ago

    Unca Alby is right, you need to use javascript to do something like that.

Still have questions? Get your answers by asking now.