これはこの質問のフォローアップであり、コードをx秒ごとに繰り返す方法を見つけました。これを変えることができるイベントを作ることは可能ですか?つまり、これを繰り返すかどうかを制御するためのチェックボックスがあるので、次のようなものが必要だと考えました。
$(checkbox).bind("change", function() {
switch(whether if it is ticked or not) {
case [ticked]:
// Make the code repeat, while preserving the ability to stop it repeating
case [unticked]:
// Make the code stop repeating, while preserving the ability to start again
}
});
何を入れたらいいのかわからないcase
。