Reverse attribute checked

Reverse attribute checked

I have a number of inputs (chk_0, chk_1 ,....) residing each in their own div.
When an input is clicked I need to reverse the "checked" value for that particular checkbox input . However I cannot find the right syntax  to do that :

Creating the inputs
  1.    $('#mydiv' + i).addClass('labelForStyler') // add class for divs
                                       .append ( "<label for='chk_" + i + "'>" + tm_traffOptions[i] + "</label><input id='chk_" + i + "' type='checkbox' value='" + tm_traffOptions[i] + "' />" ) // // add elements and attributes
 
So how to swap the checked value as soon an input is clicked  ?

thx