First part of code works perfect, including: mouseover
, mouseout
and click
event on id, called #active-to-do-list-28
. But when click event changes attribute value, it doesn't react to id, called #inactive-to-do-list-28
.
Code:
<script>
$(document).ready(function(){
$("#active-to-do-list-28").mouseover(function(){
$("#active-to-do-number-28").attr("class", "label label-info");
});
$("#active-to-do-list-28").mouseout(function(){
$("#active-to-do-number-28").attr("class", "label label-default");
});
$("#active-to-do-list-28").click(function(){
$("#active-to-do-list-28").attr("class","list-group-item list-group-item-info");
$("#active-to-do-list-28").attr("id", "inactive-to-do-list-28");
$("#active-to-do-number-28").attr("class", "label label-info");
$("#active-to-do-number-28").attr("id", "inactive-to-do-number-28");
});
$("#inactive-to-do-list-28").click(function(){
$("#inactive-to-do-list-28").attr("class", "list-group-item");
$("#inactive-to-do-list-28").attr("id", "active-to-do-list-28");
$("#inactive-to-do-number-28").attr("class", "label label-default");
$("#inactive-to-do-number-28").attr("id", "active-to-do-number-28");
});
});
</script>
Could anyone help me fix this problem?