understanding clicks behaviour
<p>I wrote this simple code to understand why if I click the "click me" text for the second time JQuery does not display the "second" text.</p>

<pre><code>&lt;div id="clickme"&gt;Click me&lt;/div&gt;
&lt;div id="sometext"&gt;This is text ZERO&lt;/div&gt;

&lt;script type="text/javascript"&gt; 
    $(document).ready(function($) {

        $("#clickme").click(function(){ 
            if (a == 1) {
                $('#sometext').replaceWith('&lt;div id="sometext"&gt;This is text TWO&lt;/div&gt;');
            }
            else {
                $('#sometext').replaceWith('&lt;div id="sometext"&gt;This is text ONE&lt;/div&gt;');
                var a = 1;
            }
        });

    });
&lt;/script&gt;
</code></pre>

<p>I expected the following behaviour:</p>

<ol>
<li>Page is loaded and the text 'This is text ZERO' is displayed</li>
<li>I click the link the first time and JQuery displays 'This is text ONE'</li>
<li>I click the link a second time and jQuery displays 'This is text TWO'</li>
</ol>

<p>Instead point #3 is not processed or at least the text is not displayed. Why?</p>
