Jquery Onclick not happening second time

前端 未结 4 757
轻奢々
轻奢々 2021-01-20 10:38

I\'m a bit confused as to why this isn\'t working; I assume that because I\'m adding the class and its not being added back into the collection I\'m not sure.

Here i

4条回答
  •  死守一世寂寞
    2021-01-20 11:18

    You can also change your click handler to the live click handler:

    $(document).ready(function () {
            $('.optional').live('click',function () {
                $(this).removeClass('optional').addClass('selected');               return false;
            });
            $('.selected').live('click',function () {
                $(this).removeClass('selected').addClass('rejected');               return false;
            });
            $('.rejected').live('click',function () {
                $(this).removeClass('rejected').addClass('optional'); 
            });
        });
    

提交回复
热议问题