Good javascript practice?
    <input type=”text” value=”click” onclick=”textClicked()”>

    <script>
    function textClicked() {
        document.write(‘Text clicked’); }
    </script>

OR

    <input id=’txt’ type=”text” value=”click”>

    <script>
    document.getElementById(‘txt’).onclick = function() { document.write('Text clicked'); } 
    </script>


Which of the above is better design practice? In my opinion it is the first one because of the re-usability it provides for function textClicked(). 

Thank you.
Good javascript practice?
===

    <input type=”text” value=”click” onclick=”textClicked()”>

    <script>
    function textClicked() {
        document.write(‘Text clicked’); }
    </script>

OR

    <input id=’txt’ type=”text” value=”click”>

    <script>
    document.getElementById(‘txt’).onclick = function() { document.write('Text clicked'); } 
    </script>


Which of the above is better design practice? In my opinion it is the first one because of the re-usability it provides for function textClicked(). 

Thank you.