jQuery - condition for if this or this

0 votes
216 views
added Nov 22, 2018 in jQuery by LC Marshal Captain (25,790 points)
var dfpElemPre  = '#div-gpt-ad-',
    dfpId       = '1542356449390-0', // sto id
    dfpElemPost = '_ad_container',
    dfpStoFront     = '.sto-ads' + ' ' + dfpElemPre + dfpId + dfpElemPost,
    dfpStoNotfront     = '.sto-ads' + ' ' + dfpElemPre + dfpId;
    
if(($(dfpStoFront).length) || ($(dfpStoNotfront).length)){
        $('.sto-ads').show();
        $('.sto-ads .slide-close').on('click', function(){
          $(this).parent().parent().removeClass('in');
        });

        if ($('body').hasClass('front')) {
          setTimeout(function(){
            $('.sto-ads').addClass('in');
          },300);
          console.log('front');
        }
        else {
          // condition for not-front 
          setTimeout(function(){
            $('.sto-ads').addClass('in');
          },300);
          console.log('not-front');
        }
      }
  console.log('create cookie');
}
else {
  $('.sto-ads').hide();
  console.log('cookie is working');
}

 

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