events javascript
<p>I need can display a message on mouse cilck. But need another message to be displayed on the next mouse click. In my code both messages appear on the first mouse click.</p>

<pre><code>&lt;!DOCTYPE&gt;
    &lt;html&gt;
        &lt;head&gt;
            &lt;script&gt;
                function myfunction()
                {
                var obj=document.getElementById("msg1");
                obj.innerHTML="message1";
                if(obj.innerHTML=="message1")
                {
                    var obj1=document.getElementById("msg2");
                    obj1.innerHTML="message2";
                }

                }
            &lt;/script&gt;

        &lt;/head&gt;
        &lt;body&gt;
            &lt;div id="msg"&gt;
                &lt;form name="myform"&gt;
                    &lt;input type="button" value="click" onclick="myfunction()"&gt;
                        &lt;p id="msg1"&gt;&lt;/p&gt;
                        &lt;p id="msg2"&gt;&lt;/p&gt;
                &lt;/form&gt;
            &lt;/div&gt;
        &lt;/body&gt;
    &lt;/html&gt;
</code></pre>
