Check if button is active
<p>I'm really struggling with this piece of code.</p>

<p><em>What I'm trying to achieve: I have an "edit button". If I press it, it'll go active and edit mode goes active. I can edit the list on the fly and it updates automatically.</em></p>

<p><strong>Problem: I can get it to work for 50%. If I try to activate the button I can edit the objects. But when I deactivate the button again I can still edit the objects. Of course that shouldn't be possible.</strong></p>

<p>Here some messy code. Yeah most of it is found online and I'm trying to edit it myself... </p>

<pre class="lang-js prettyprint-override"><code>$("#editButton").click(function() {
    $("#editButton").toggleClass("active");
    if ($("#editButton").hasClass("active")) {
        $(".moveLi").on("click", function() {
            var ID = $(this).attr('id');
            $("#move_"+ID).hide();
            $("#move_edit_"+ID).show();
        }).change(function() {
            var ID = $(this).attr('id');
            var first = $("#move_edit_"+ID).val();
            var dataString = 'id=' + ID + '&amp;name=' + first;
            $("#move_"+ID).html('&lt;p&gt;Saving...&lt;/p&gt;'); // Loading image

            if (first.length &gt; 0) {
                $.ajax({
                    type: "POST",
                    url: "table_edit_ajax.php",
                    data: dataString,
                    cache: false,
                    success: function(html) {
                        $("#move_"+ID).html(first);
                    }
                });
            }
            else {
                alert('Enter something.');
            }
        });

        $(".editbox").mouseup(function()  {
            return false
        });

        $(document).mouseup(function() {
            $(".editbox").hide();
            $(".text").show();
        });
    } 
});
</code></pre>

<p>Thanks in advance!</p>
