All pastes #986041 Raw Edit

Stuff

public text v1 · immutable
·published 2008-04-15 14:07 UTC
rendered paste body
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
    <head>
        <title>004.testing.function.assignment.to.dom.elements.html</title>
    </head>
    <body>

        <table>
            <tr>
                <td style="border: 1px red dashed; padding: 40px;">

                    <div id="root"></div>
                </td>
            </tr>
        </table>

        <script type="text/javascript">

function go() {
    var root = document.getElementById("root"); {
        root.ct_form = document.createElement("form");
        root.appendChild( root.ct_form );

        root.event_fn = function() {
            alert('event_fn');
        }

        var button = document.createElement('input'); {
            button.setAttribute('type', 'button');
            button.setAttribute('onClick', function() {root.event_fn()});
        }
        root.ct_form.appendChild(button);

        alert(button.getAttribute('onClick'));
    }

}

go();

        </script>

    </body>
</html>