gpt4 book ai didi

jQuery Cycle2 插件 : hide controls if only 1 image

转载 作者:行者123 更新时间:2023-12-01 04:54:31 24 4
gpt4 key购买 nike

我创建了一个 WordPress 网站,我已将 Cycle2 插件集成到图库中。当用户添加超过 1 个图像时,将显示控件并开始幻灯片转换。我希望控件在只有 1 个图像时隐藏。我有一段代码可以帮助流程的开发,但尝试将 css display:none 添加到函数中,但没有任何反应。如果有人可以指导我,那就太好了,因为我尝试了不同的方法。

插件:http://www.malsup.com/jquery/cycle2/

CSS:

.cycle-slideshow {
height:400px;
z-index:0;
}
.cycle-slideshow img{
width:100%;
height:100%;
z-index:3;
}
.center {
display:block;
}
.center a{
z-index:4;
position:absolute;
margin-top:-48px;
}
.center a:hover {
display:block;
}
.center a#prev, .center a#next{
position:relative;
width:4%;
height:60px;
width:60px;
margin-top:-60px;
font-size:40px;
text-align:center;
color:#FFF;
}
.center a#next{
float:right;
background:url(images/next.png) center -2px no-repeat;
}
.center a#prev {
float:left;
background:url(images/prev.png) center -2px no-repeat;
}

HTML:这个 html 很大并且集成到 php 函数中,但它的内容是:

<div class="cycle-slideshow" 
data-cycle-fx=fadeout
data-cycle-timeout=1000
data-cycle-pause-on-hover="true">
<img src="http://malsup.github.com/images/p1.jpg">
...
</div>

jQuery 片段(我很困惑):

$(document).ready(function () {   
$('.cycle-slideshow').on( 'cycle-initialized', function( e, opts ) {
if ( opts.slideCount > 1 ) {
$(".center").css("display", "none");
}
});
});

我的控制台中也没有收到任何错误。

最佳答案

您说您希望在只有一张图像时隐藏控件。但是:

if ( opts.slideCount > 1 ) {
$(".center").css("display", "none");
}

当有不止一张图像时,您可以隐藏它们。

关于jQuery Cycle2 插件 : hide controls if only 1 image,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15643264/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com