jQuery .click() .toggle() - change display and swap character

后端 未结 2 1331
清歌不尽
清歌不尽 2021-01-22 16:02

Here is my jQuery:

$(\'.ask\').click(function() {
    $(\'.addtitle\').slideToggle(\'fast\', function() {
    // Animation complete.
    });
});
<
2条回答
  •  轮回少年
    2021-01-22 16:15

    $('.ask').click(function() {
      var $this = $(this);
    
      $this.find('.addtitle').slideToggle('fast', function() {
         // Animation complete.
         if($this.text() === '-')
            $this.text('+');
         else
            $this.text('-');
      });
    });
    

提交回复
热议问题