Results 1 to 3 of 3

Thread: function to make set a <div> invisible ?

  1. #1
    Join Date
    Jul 2010
    Posts
    29
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default function to make set a <div> invisible ?

    Is it possible to use the onClick on a button to make the contents of a <div> invisible ?

  2. #2
    Join Date
    Mar 2011
    Posts
    1,767
    Thanks
    59
    Thanked 102 Times in 100 Posts
    Blog Entries
    4

    Default

    Code:
    <html>
    <head>
    <script type="text/javascript">
    function hideMe() {
    var id = document.getElementById('div1');
    id.style.display = "none";
    }
    </script>
    </head>
    <body>
    <input type="button" value="Hide Div" onclick="hideMe()">
    <div id="div1">
    Dynamic Drive Forums
    </div>
    </body>
    </html>
    Last edited by keyboard; 04-12-2012 at 10:30 PM. Reason: Added in dd forums between div

  3. #3
    Join Date
    May 2010
    Location
    Sacramento, CA
    Posts
    91
    Thanks
    23
    Thanked 2 Times in 2 Posts

    Default

    Yes, you can hide the div or erase the innerHTML

    Hide dive:
    Code:
    onClick="document.getElementById('divId').style.display="none";
    Erase html content from div:
    Code:
    onClick="document.getElementById('divId').innerHTML="";

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •