我有这个:
$('#mask').cycle({
fx: 'scrollLeft',
timeout: 0,
speed: 300,
startingSlide: 0
});
但是在某些情况下,我希望 fx 是 scrollRight 让我们说什么时候(myCondition == true)
我怎么做?
我有这个:
$('#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:
为 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
});
}