jQuery - click and click again on the same element

0 votes
247 views
added Jun 21, 2019 in jQuery by LC Marshal Captain (25,790 points)
function showBtnDefault () {
  $(shareBtn).removeClass('on-click');
  $('.share-news-content > img.ico').attr('src', defIco);
  $(shareBox).removeClass('in');
  $('html, body').css({ overflow: 'auto',height: 'auto'});
}

$(shareBox).each(function () {
  $(this).on('click', function(){
    showBtnDefault();
  });
  
  $(shareBtn).on('click', function(){
    $('html, body').css({overflow: 'hidden', height: '100%'});
    $(shareBox).addClass('in');
    $('.share-news-content > img.ico').attr('src', closeIco);
    $(this).addClass('on-click');
  });
  var open = false;
  $(shareBtn).click(function() {
      open = !open;

      if(open) {
          console.log('11');
      } else {
        showBtnDefault();
      }
  });
});

 

lazacode.org - Malaysia's programming knowledge sharing platform, where everyone can share their finding as reference to others.
...