How do, when click a checkbox, in var check=''; will be added - okay,
and if click again,okay开发者_StackOverflow will be removed.
How it make?
var check = "";
$("#yourcheckbox").change(function() {
    if($(this).is(":checked")) {
        check = "okay";
    }
    else {
        check = "";
    }
});
This does exactly what you ask, but the solution posted by @Rikudo is better if you can live without check having to contain "okay".
var check = false;
console.log(check);
$('#checkbox').change(function() {
    check = $(this).is(':checked');
    console.log(check);
});
Will set the variable to true or false depending on the state.
Example.
var check;
$('#checkbox').change(function() {this.checked ? check = 'okay' : check = '';})
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论