我有这个:
$('#mask').cycle({
fx: 'scrollLeft',
timeout: 0,
speed: 300,
startingSlide: 0
});
但是有一种情况我想让fx成为scrollRight让我们说什么时候(myCondition == true)
我该怎么做?
答案 0 :(得分:0)
这应该有用..
(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";
}
答案 1 :(得分:0)
var myFx = 'scrollLeft';
if( window.location.href.indexOf('myCondition=true') != -1 ) {
myFx = 'scrollRight';
}
$('#mask').cycle({
fx: myFx,
timeout: 0,
speed: 300,
startingSlide: 0
});
答案 2 :(得分:0)
我要走出困境并假设要向右滚动,你将fx:
更改为scrollRight。在那种情况下
if(myCondition == true) {
$('#mask').cycle({
fx: 'scrollRight',
timeout: 0,
speed: 300,
startingSlide: 0
});
} else {
$('#mask').cycle({
fx: 'scrollLeft',
timeout: 0,
speed: 300,
startingSlide: 0
});
}