为什么Java单击事件不起作用

时间:2019-12-02 10:42:55

标签: javascript events dom-events

我正在尝试复制本教程:

https://tympanus.net/codrops/2016/09/29/transition-effect-with-css-masks/ 当我单击箭头时,它应该滑动到另一个包装器并启动动画,但是由于某种原因,我无法在Jquery中对其进行更改和变形,但仍然无法实现

                     function init() {
                        ......

                          Slider.prototype.events = function () {
                          var self = this;
                          this.dom.arrow.on('click', function () {
                            if (self.working)
                            return;
                            self.processBtn($(this));
                          });
                       };
                     .-....
                    }

可能是什么错误?

2 个答案:

答案 0 :(得分:0)

try for loop

 fifi_slider.prototype.buildDots = function () {
      var _ = this;
      for (var i = 0; i < _.totalSlides; i++) {
        var dot = document.createElement('li');
        dot.setAttribute('data-slide', i + 1);
        _.def.dotsWrapper.appendChild(dot);
      }
      _.def.dotsWrapper.addEventListener('click', function (e) {
        if (e.target && e.target.nodeName == "LI") {
          _.curSlide = e.target.getAttribute('data-slide');
          _.gotoSlide();
        }
      }, false);
    }

答案 1 :(得分:0)

您忘记向箭头选择器添加DOT。

https://codepen.io/besciualex/pen/YzPzGOw?editors=1111

// Previous selector value (without DOT)
this.dom.arrow = this.dom.wrapper.find('arrow');

// Correct selector value (with DOT)
this.dom.arrow = this.dom.wrapper.find('.arrow');