How to append html only if the div is empty in jQuery?
<p>I have this code for displaying content for login and registration in my PHP file:</p>

<pre><code>&lt;?php // LOGIN PART ?&gt;
&lt;div class="login-part"&gt;&lt;/div&gt;

&lt;?php // REGISTRATION PART ?&gt;
&lt;div class="registration-part"&gt;&lt;/div&gt;
</code></pre>

<p>And this in my js file:</p>

<pre><code>$(document).ready( function() {
            // FOR REGISTRATION
            $('span.logreg.reg').click(function () {

                $('div.registration-part').append('&lt;p&gt;Registration&lt;/p&gt;');
            });

            // FOR LOGIN
            $('span.logreg.log').click(function () {

                // insert html
                $('div.login-part').append('&lt;p&gt;Login&lt;/p&gt;');
            });
        });
</code></pre>

<p>Now, everytime I click on a span it shows the text login or registration, according to which of the span was clicked. </p>

<p>Thats OK, however I need to add it only once, so when the user click more times on the span it will be not adding more text.</p>

<p>Remove() or empty() is not an option, as far as I know, because I need the information inside input boxes (there will be input boxes later for inserting user info) to stay there and not be deleted if the user click accidentally on the span again.</p>

<p>It can however delete the html inside the div, if he clicks on another span. E.g. if span.log is active, after clicking on span.log nothing happens, but if he clicks on span.reg the html inside div.login-part will be removed and registration text will appear.</p>

<p>How to do something like this?</p>
