根据cookie.js禁用div

时间:2016-05-06 14:39:58

标签: javascript php

以下代码有效,但当我尝试在弹出窗口中使用它时,它无法使用cookie.js

这部分标题为

<script type='text/javascript'>//<![CDATA[ 
  $(window).load(function(){
    $(document).ready(function () {
      $('#yes').on('click', 'a.disabled', function (e) {
        onclickLink(e, $(this));
      });
      $("#yes").on('click', '#remove', function (e) {
        alert('You are free to visit the page again');
        $.removeCookie('link_disabled');
      });
    });

    function onclickLink(event, this1) {
      if ($.cookie('link_disabled') === null || $.cookie('link_disabled')==undefined) {
        /* do whatever you want with link*/
        $.cookie("link_disabled", 1, {
          expires: 5
        });
        alert('Click OK to post your campaign NOW! You will only be allowed to boost a new campaign after 5 days.');
        /*setting the cookie for 5 days*/
      } else {
        alert('You Have Already Boost This Campaign!');
        event.preventDefault();
      }
    }
  });//]]>
</script>

这部分正文

<!-- Boost -->
<div id="yes"> 
    <br><a href="post.php" class="disabled"><img src="../../../img/boost.png"   alt="Logo" /></a>
    <br>
</div>

当尝试弹出时它确实执行post.php文件但不禁用div这里是弹出窗口中的代码

<a href="#boost" data-rel="popup" data-position-to="window"><img   src="http://mymobi.cards/images/button-boost.png" align="bottom"  style="padding-left: 25px; padding-top: 10px"></a>
    <div data-role="popup" id="boost"><a data-rel="back" data-icon="delete" >
</a>
<div data-role="content" id="centerlocation">
    <h2>Boost Your Campaign on Facebook</h2>
    <img src="images/compressed-slide1.jpg"><br><br>

    <div id="yes"> 
        <br><a href="post.php" class="disabled"><img src="../../../img/boost.png"  alt="Logo" /></a>
        <br>
    </div>
</div>

0 个答案:

没有答案