Jquery simple if statement confusion
<p>I got a confirmation alert to confirm a user action.</p>

<p>on click "ok", it should do the following code:</p>

<pre><code>function disableSubmitButton() {
    jQuery("#submitButton").attr("disabled", "true");
    jQuery("#rent_space").submit();
}
</code></pre>

<p>on "cancel", the following.</p>

<pre><code>if (!confirm('Are you sure you want to proceed ?')) {
    return false;
}
</code></pre>

<p>However, the way my code is currently formated, the first block of code is executed regardless of which button is pressed.</p>

<p>I think this is pretty much just moving the code around, but I'm unsure how to correctly do it as my precedent attempts all failed. Any help appreciated. Thanks !</p>

<p>Full code:</p>

<pre><code>&lt;script&gt;
    jQuery(document).ready(onDocumentReady);
        function onDocumentReady() {

            jQuery("#submitButton").click(disableSubmitButton);

            jQuery('#submitButton').click(function() {
                if (!confirm('Are you sure you want to proceed ?')) {
                    return false;
                }
            });

        }
        function disableSubmitButton() {
            jQuery("#submitButton").attr("disabled", "true");
            jQuery("#rent_space").submit();
        }
&lt;/script&gt;
</code></pre>
