laresiduum :
actually I'm using a responsive carousel jQuery plugin (slick) for my website, which works really well.
Now I want the command 'autoplay: true' to be managed by a separate variable 'ausgabe', that depends on an the existence of an id-tag. My if-clause is already working, but I have absolutely no clue how to define 'autoplay = ausgabe'. Is this possible?
In order to make a clearer question, here is my code:
<script type="text/javascript">
if ($('#comment-preview').length != 0) {
ausgabe = "true";
} else {
ausgabe = "false";
}
$(document).ready(function(){
$('.slideshow-container').slick({
dots: true,
speed: 500,
(
autoplaySpeed: 5000,
infinite: true,
slidesToShow: 3,
slidesToScroll: 1,
responsive: [
{
breakpoint: 800,
settings: {
slidesToShow: 2,
slidesToScroll: 1
}
},
{
breakpoint: 480,
settings: {
slidesToShow: 1,
slidesToScroll: 1
}
}
]
});
});
</script>
And yes, I'm a absolute rookie.
Thanks a lot!
Rory McCrossan :
If you check the slick slider docs, the autoplay
property needs to be a boolean, not a string as you're currently creating. As such you can just provide it the result of the condition you check without the need to create the ausgabe
variable, like this:
$(document).ready(function() {
$('.slideshow-container').slick({
autoplay: $('#comment-preview').length != 0,
// other properties...
});
});
Guess you like
Origin http://10.200.1.11:23101/article/api/json?id=398575&siteId=1