如何在每个用户每天点击2次后禁用<div>

时间:2017-07-16 13:49:54

标签: javascript jquery html css cookies

我想知道我该如何做到这一点 每位用户每天只能点击2次,如果用户点击该广告,我该如何在新窗口中打开该广告

&#13;
&#13;
<div class="thumbnail">
  <script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script>

  <ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-" data-ad-slot="" data-ad-format="auto"></ins>
  <script>
    (adsbygoogle = window.adsbygoogle || []).push({});
  </script>
</div>
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:0)

var clickedAd = [null, null];
document.getElementById("myCheck").onclick = function(){
clickedAd.forEach(function(idx, ele){
    if(ele == null){
        ele[idx] = "something";
    }
}
if(clickedAd[1] !== null){
    document.getElementById("id-to-hide").style.display = "none";
    setTimeout(function(){
        clickedAd = [null, null];
    }, 86400000);
} else {
document.getElementById("id-to-hide").style.display = "block";
}
};

这样的事情应该做的事情