2
我已經創建了一個wordpress網站,我已經將cycle2插件集成到了圖庫中。當用戶添加多個圖像時,控件顯示並開始幻燈片切換。我想讓控件在只有一個圖像時隱藏。我有一段代碼可以幫助開發過程,但嘗試在函數中添加css display:none並且沒有任何反應。如果有人能指導我,這將是偉大的,因爲我嘗試了不同的方法。jQuery cycle2插件:如果只有1個圖片隱藏控件
插件: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");
}
});
});
我也沒有在我的控制檯中的錯誤。