checked button on off depending on a result

checked button on off depending on a result

Hi,
I have created a on-off button with the following code. Now I want to make it switch from on to off when a value is read I am using these options:  $ ( '#red' ). attr ( 'checked' , 'checked' ); to check it and uncheck it  $ ( '#red' ). removeAttr ( 'checked' );  but nothing changes.Have you got any ideas?
  1. $("input[type=checkbox]").switchButton({ width: 100, height: 40, button_width: 70 });
  2.  "<input id=\"red\" name=\"red\" type=\"checkbox\" value=\"1\" checked>"