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


    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.

    #toggleMe {background:#cfc; display:none; margin:30px 0; padding:1em;}
    <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>
        changeDisplayState = function (id) {
            var d = document.getElementById('showhide'),
                e = document.getElementById(id);
            if ( === 'none' || === '') {
       = 'block';
                d.innerHTML = 'Hide paragraph';
            } else {
       = 'none';
                d.innerHTML = 'Show paragraph';
        document.getElementById('showhide').onclick = function () {
            return false;

Leave a Reply

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