jQuery:根据您在导航中的位置,我如何产生不同的效果
-
04-10-2019 - |
题
我有这个:
$('#mask').cycle({
fx: 'scrollLeft',
timeout: 0,
speed: 300,
startingSlide: 0
});
但是在某种情况下,我希望FX成为Scrollright,请说何时(mycondition == true)
我怎么做?
解决方案
这应该有效..
(myCondition == true) ? _fx = "scrollLeft" : _fx = "scrollRight";
$('#mask').cycle({
fx: _fx,
timeout: 0,
speed: 300,
startingSlide: 0
});
做一个 _fx()
功能,不过..
function _fx(c) {
return (c == true) ? "scrollLeft" : "scrollRight";
}
其他提示
你的意思是:
var myFx = 'scrollLeft';
if( window.location.href.indexOf('myCondition=true') != -1 ) {
myFx = 'scrollRight';
}
$('#mask').cycle({
fx: myFx,
timeout: 0,
speed: 300,
startingSlide: 0
});
我要肢体出去,假设要滚动你更改 fx:
要滚动。在这种情况下
if(myCondition == true) {
$('#mask').cycle({
fx: 'scrollRight',
timeout: 0,
speed: 300,
startingSlide: 0
});
} else {
$('#mask').cycle({
fx: 'scrollLeft',
timeout: 0,
speed: 300,
startingSlide: 0
});
}
不隶属于 StackOverflow