猿问

手风琴菜单多次狂点击后,当鼠标不点击了还会出现点击的效果,怎么解决的

$(function() {

var Accordion = function(el, multiple) {

this.el = el || {};

this.multiple = multiple || false;


// Variables privadas

var links = this.el.find('.ctitle');

// Evento

links.on('click', {el: this.el, multiple: this.multiple}, this.dropdown)

}


Accordion.prototype.dropdown = function(e) {

var $el = e.data.el;

$this = $(this),

$next = $this.next();


$next.slideToggle();

$this.parent().toggleClass('open');


if (!e.data.multiple) {

$el.find('.submenu').not($next).slideUp().parent().removeClass('open');

};

}

var accordion = new Accordion($('#accordion'), false);

});


hnmw
浏览 1991回答 3
3回答

Despicableme01

jq的.stop()方法,停止元素上所有的动画,可以$next.stop().slideToggle()

Cocoon3496659

可能因为你点击的太快了,电脑在一次次执行你点击的动作。
随时随地看视频慕课网APP
我要回答