jQuery - change background on click

0 votes
83 views
added Jun 20, 2019 in jQuery by LC Marshal Captain (25,770 points)
$(window).load(function() {  
  var shareBtn = $('.share-news-content'),
      shareBox = $('.share-news-content-box'),
      closeIco = 'http://mysite.com/assets/icons/share-color-24.svg',
      closeBtn = $('.share.on-click');

  $(window).scroll(function() {
    if (window.scrollY > 70) {
      shareBtn.addClass('pos-fixed share');
    } else {
      shareBtn.removeClass('pos-fixed share');
    }
  }); 
  $(shareBox).each(function () {
    $(shareBtn).on('click', function(){
      $(shareBox).addClass('in');
      $('.share-news-content > img.ico').attr('src', closeIco);
      $(this).addClass('on-click');
      console.log('click')
    });
    // if($(shareBtn).data('clicked')) {
    //   console.log('rrrrr')
    //   // code here 
    // }
    if ($('.share.on-click').length) {
      console.log('heyyy');
    };
  });
});

 

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