How to stop this function?

I have a function that I want to stop and start using the CheckBox. The question arose of how to stop it when the CheckBox is not active?
here's an example: https://codepen.io/norbert_Pacoc/pen/zQVWvr
March 23rd 20 at 19:29
2 answers
March 23rd 20 at 19:31
Solution
Thank you - norbert_Pacoc commented on March 23rd 20 at 19:34
@norbert_Pacocbetter way https://codepen.io/anon/pen/YbovKP - Olin.Moe commented on March 23rd 20 at 19:37
March 23rd 20 at 19:33
$('input[type="checkbox"]').change(function(){
if ($(this).is(":checked") {
// do this
}
else {

}
})
In this case, how to stop the function when the CheckBox is not active, that is to stop the function via else? - norbert_Pacoc commented on March 23rd 20 at 19:36

Find more questions by tags jQuery