Can someone tell me why this jQuery script does not work?
<p>Here is my code.</p>

<pre><code>function switchbox(showall, maincls) {
    $(showall).change(function() {
        if ($(this).is(":checked")) {
        $(maincls).each(function(i) {
            $(this).attr('disabled', true);
        });
        } else {
        $(maincls).each(function(i) {
            $(this).attr('disabled', false);
        });
        }
    });
}

switchbox('.show-all-tags, .tags');
switchbox('.show-all-cats, .categories');
</code></pre>

<p>It works if i didn't use variables inside the function. It should disable all checkboxes of that class when the show-all-X is checked and vice versa. and i tried it without the variables showall, maincls it works. What I am doing wrong here please?</p>

<p>Thank you.</p>
