Welcome Guest, Not a member yet? Register   Sign In
jQuery: check/uncheck all checkboxes with specific value
#4

[eluser]Nick Husher[/eluser]
Note that the @property=value syntax has been depricated since jQuery 1.2. From the documentation: "Note: In jQuery 1.3 [@attr] style selectors were removed (they were previously deprecated in jQuery 1.2). Simply remove the '@' symbol from your selectors in order to make them work again."

This is very similar, but lets you control what values you check and uncheck without rewriting your function:

Code:
jQuery(document).ready(function() {
    jQuery('.toggle').click(function(e) {
        var par = (/parent-class-(\S+)/).exec(e.target.className)[1];
        var val = (/toggle-value-(\S+)/).exec(e.target.className)[1];

        par = (par === null) ? par = '' : '.'+par;
        val = (val === null) ? val = '' : '[value="'+val+'"]';

        jQuery(par + ' input[type="checkbox"]' + val).each(function() {
            this.checked = !this.checked;
        });
    });        
});

Your toggle button would look something like this:
Code:
<div class="toggle toggle-value-5 parent-class-checkbox-form">Toggle all "fives" in the "checkbox form"</div>


Messages In This Thread
jQuery: check/uncheck all checkboxes with specific value - by El Forum - 02-11-2009, 03:17 PM



Theme © iAndrew 2016 - Forum software by © MyBB