Search code examples
javascripthtmlicheck

how to reverse selection with iCheck


I'm useing iCheck. Now i need to reverse selection when click on the reverse checkbox. I don't know how to do this. Has somebody done this before?

html

<input type="checkbox" id= "category_ids_select_reverse" name="category_ids_select_reverse">Reverse
<input type="checkbox" name="category_ids_select" value="">

js

var category_ids_select_reverse= $('#category_ids_select_reverse');
category_ids_select_reverse.on('ifChanged', function () {
    // how to reverse the selection?
});

Solution

  • you can use iCheck('toggle')

    $('#category_ids_select_reverse').on('ifClicked', function(){
            $('input[name="category_ids_select"]').iCheck('toggle');
    });
    

    Sample : jsfiddle