I have a html page.This is the code:
<script src="jquery-1.10.1.min.js"></script>
<script>
$('document').ready(function(){
$(".class-1").click(function(){
id=this.id;
alert(id);
$("#"+id).removeClass("class-1");
$("#"+id).addClass("class-2");
});
});
</script>
<style>
.class-1{color:red;}
.class-2{color:blue;}
</style>
<div class="class-1" id="id-1">sth</div>
When I click the div for the first time, page alerts the id, and the class and color changes.
The problem: When I click on it for the second and third time, it alerts the id again, But it shouldn't. Because the class is changed. So what is the problem?