class oldClassを持つHelloという単語をクリックすると、jqueryはnewClassクラスにクラスを変更します。これは単語Hello Blueを色付けします。これは、クラスが変更されたことを意味します。 jQueryがnewClassクラスのクリックに応答しないのはなぜですか?jquery changed classが反応しません
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
<script>
$(document).ready(function(){
$(".oldClass").click(function(){
$(".oldClass").attr("class","newClass");
});
$(".newClass").click(function(){
$(".newClass").attr("class","oldClass");
});
});
</script>
<style>
.oldClass {color:red;}
.newClass {color:blue;}
</style>
</head>
<body>
<p class="oldClass">Hello</p>
</body>
使用 '.toggleClass()' [デモ](https://jsfiddle.net/x9e06kmo/) –
役立つことを願っています:jQueryのは、HTTPS addClassとremoveClass機能を実装://api.jquery.com/addclass/ –