Code: Select all
$(document).ready(function()
{
$("#email_all").click(function()
{
var checked_status = this.checked;
$("input[@id=email]").each(function()
{
this.checked = checked_status;
});
});
});
1) How can I change this code so I can invert the current selection, rather than check/uncheck all at once
2) How can I put this code into a function so I can reuse the code above by simply passing the email_all and email
I put it into a function and called the function in the onclick of the checkbox which is used to select/unselect checkboxes but nothing happened, I assumed because the first click() in the code above is being called inside it self it's causing an issue???
Any ideas, suggestions would be great, thanks.