jQuery での html タグのクラスの切り替えについて質問がありました
今、私は次のようなコードを持っています
<body>
<button id="login" class="login">login</button>
<script>
jQuery(function($){
$('.logout').click(function(){
$(this).removeClass('logout');
$(this).addClass('login');
$(this).text('login');
alert('logged out, ready to login');
});
$('.login').click(function(){
$(this).removeClass('login');
$(this).addClass('logout');
$(this).text('logout');
alert('logged in, ready to logout');
});
});
</script>
</body>
どのクラスであっても $('.login').click を常に実行するのはなぜだろうか。
ありがとう