Wikipedia


Using a DOM function

Show paragraph

This is the paragraph that is only displayed on request.

The general flow of the document continues.


One thought on “Wikipedia

  1. shinichi Post author

    Dynamic HTML

    Wikipedia

    http://en.wikipedia.org/wiki/Dynamic_HTML

    Dynamic HTML, or DHTML, is an umbrella term for a collection of technologies used together to create interactive and animated web sites by using a combination of a static markup language (such as HTML), a client-side scripting language (such as JavaScript), a presentation definition language (such as CSS), and the Document Object Model (DOM).

    Example: Displaying an additional block of text

    The following code illustrates an often-used function. An additional part of a web page will only be displayed if the user requests it.

    <style>
    #toggleMe {background:#cfc; display:none; margin:30px 0; padding:1em;}
    </style>
      
    <h1>Using a DOM function</h1>
     
    <h2><a id="showhide" href="#" rel="nofollow">Show paragraph</a></h2>
     
    <p id="toggleMe">This is the paragraph that is only displayed on request.</p>
     
    <p>The general flow of the document continues.</p>
     
    <script>
        changeDisplayState = function (id) {
            var d = document.getElementById('showhide'),
                e = document.getElementById(id);
            if (e.style.display === 'none' || e.style.display === '') {
                e.style.display = 'block';
                d.innerHTML = 'Hide paragraph';
            } else {
                e.style.display = 'none';
                d.innerHTML = 'Show paragraph';
            }
        };
        document.getElementById('showhide').onclick = function () {
            changeDisplayState('toggleMe');
            return false;
        };
    </script>
    
    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *