jQuery : Use an alternative to .toggle() which is deprecated

前端 未结 4 899
一生所求
一生所求 2021-01-13 23:52

I have some images with class name \".mute_btn\" and when i click on them, my images source is changing :

$(\'.mute_btn\').toggle(function () {
        var c         


        
4条回答
  •  温柔的废话
    2021-01-14 00:26

    The code that I use:

    $('#example').click(function()
        {
        isClicked=$(this).data('clicked');
        if (isClicked) {isClicked=false;} else {isClicked=true;}
        $(this).data('clicked',isClicked);
    
        if(isClicked)
            {
            ...do stuff...
            }
        else
            {
            ...do stuff...
            }
        });
    

提交回复
热议问题