单击链接时关闭.on

时间:2016-07-10 06:21:08

标签: jquery swipe

我创建了以下代码,该代码适用于.on函数所需的内容,但当我点击#close_box链接时,如何设置.on到{{{}}的内容除非我点击.off链接?

,否则它不会反对



.mcndiv

$(document).ready(function() {
  $(".mcndiv").click(function() {
    // Bind the swipeHandler callback function to the swipe event on div.box
    $("#mc-container").on("swipeleft", swipingLeft);
    $("#mc-container").on("swiperight", swipingRight);
    // Callback function references the event target and adds the 'swipe' class to it
    function swipingLeft() {
      $('#mcnumbers-links #mcnumbers-colours a.mcselected').removeClass('mcselected')
    }

    function swipingRight() {
      $('#mcnumbers-links #mcnumbers-colours a.mcselected').addClass('mcselected')
    }
    $('#close_box').click(function() {
      $("#mc-container").off("swipeleft", swipingLeft);
      $("#mc-container").off("swiperight", swipingRight);
    });
  });
});

.mcselected {
  background: blue;
}

a {
  width: 50px;
  height: 50px;
  display: block;
  background: green;
}

.mcndiv {
  width: 100px;
  height: 50px;
  background: red;
  color: white
}




修改

我试图让移动jquery在示例中工作,但是它在我的localhost网站上没有工作..它是?但是如果有意义的话,试图让.on成为.off?所以,如果我在点击#close_box后​​滑动它什么都不做?

谢谢堆:)

0 个答案:

没有答案