Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
以下のコードにはエラーがないように思えますが、何らかの理由で、クリック時に変数の値が単純に変更されるわけではありません。どんな助けでも素晴らしいでしょう。
var test = 1; $("div").click(function() { test = 0; }); if (test == 0) { $("p").html("hello"); }
これは基本的な質問であり、広範囲に検索しましたが、解決策が見つかりませんでした.
if ステートメントが実際のクリック ハンドラー内にない
var test = 1; $("div").click(function() { test = 0; if (test == 0) { $("p").html("hello"); } });
そのため、実際には Click でテストされていませんでした。