帮忙修改下,如果把click修改成mouseover与mouseout的效果?
谢谢。$(document).ready(function() {
$('#tab-nav-1 > ul > li > a').overmouse(function() {
var $parentItem = $(this).parent(),
slideAmt = $(this).next().width(),
direction; if (parseInt($parentItem.css('marginLeft'), 10) < 0) {
direction = '+=';
$(this).removeClass('expanded');
} else {
$(this).addClass('expanded');
direction = '-=';
}
$parentItem
.animate({marginLeft: direction + slideAmt}, 400);
return false;
});
});
谢谢。$(document).ready(function() {
$('#tab-nav-1 > ul > li > a').overmouse(function() {
var $parentItem = $(this).parent(),
slideAmt = $(this).next().width(),
direction; if (parseInt($parentItem.css('marginLeft'), 10) < 0) {
direction = '+=';
$(this).removeClass('expanded');
} else {
$(this).addClass('expanded');
direction = '-=';
}
$parentItem
.animate({marginLeft: direction + slideAmt}, 400);
return false;
});
});
我先前把click改成overmouse,然后把下面的IF,ELSE拆开来分别定义,但是没有成功,所有求助大家来。
mouseover做什么? mouseout 又做什么呢?
你要说明白你要实现什么功能,什么效果撒!
direction = '+=';
$(this).removeClass('expanded');mouseout 执行:
$(this).addClass('expanded');
direction = '-=';就是把IF 和 ELSE拆开变成两个事件。
$(document).ready(function() {
$('#tab-nav-1 > ul > li > a').click(function() {
var $parentItem = $(this).parent(),
slideAmt = $(this).next().width(),
direction; if (parseInt($parentItem.css('marginLeft'), 10) < 0) {
direction = '+=';
$(this).removeClass('expanded');
} else {
$(this).addClass('expanded');
direction = '-=';
}
$parentItem
.animate({marginLeft: direction + slideAmt}, 400);
return false;
});
});