What to use instead toggle?

前端 未结 1 942
情书的邮戳
情书的邮戳 2020-12-21 10:46

I learned that function toggle() is deprecated. So what can i use instead toggle for this example:

1条回答
  •  轮回少年
    2020-12-21 11:39

    You can use click and slideToggle method.

    $("#click").click(function(){
         var $block = $("#block"),
             $this = $(this);
         $block.slideToggle(function(){
             $this.text($block.is(':visible') ? 'hide' : 'show');
         });
    });
    

    0 讨论(0)
提交回复
热议问题