当我关闭它们时,我遇到了让我的div动画的问题。任何帮助,为什么它不会有帮助。
$(function() {
$('a[href*=#]:not([href=#])').click(function() {
if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
var target = $(this.hash);
target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
if (target.length) {
$('html,body').animate({
scrollTop: target.offset().top
}, 1000);
return false;
}
}
});
});
$(document).ready(function() {
$('.bar1').click(function() {
$('#full1').toggleClass('open', 900);
});
$('.bar2').click(function() {
$('#full2').toggleClass('open', 900);
});
$('.bar3').click(function() {
$('#full3').toggleClass('open', 900);
});
$('.bar4').click(function() {
$('#full4').toggleClass('open', 900);
});
});
答案 0 :(得分:1)
如果我理解你的问题,你的问题是toggleClass不做动画。你应该使用jQuery的switchClass。
此question也可能有所帮助。
答案 1 :(得分:0)
除了switchClass,你还可以使用toggle()。看到这个小提琴:http://jsfiddle.net/7U9QY/2/
只需将toggleClass更改为切换(600)
即可$(document).ready(function() {
$('.bar').click(function() {
$('.full').toggle(600);
});
如果你只想要点击的div,可以使用它:http://jsfiddle.net/7U9QY/8/
$(this).closest('a').siblings('div').toggle(600);
所以找到最近的a然后在兄弟姐妹中找到div。另一种解决方案是:
$(this).parent().parent().children('.full').toggle(600);