我在我的网站上有滑块,我想在里面显示随机照片。我的HTML代码如下:在我的网站滑块上显示随机照片
<li class="swiper-slide item telef" data-id="1" style="width:250px; height:10px;">
<div class="phone" style="display:none;">
<a href="http://xxx.pl/pl/xxxx/prestizowy/_/apple_iphone_7_256_gb">
<img src="<?= $basePath ?>images/iphone7_sl.png"
style="width:130px; height:250px; margin-left:auto;
margin-right:auto;" alt="">
</a>
<div class="caption">
<a href="http://xxxx.pl/pl/xxxxx/prestizowy/_/apple_iphone_7_256_gb">
iPhone <strong>7</strong>
</a>
</div>
</div>
</li>
我有大约20列表项和我的jQuery脚本是:
$(document).ready(function() {
display = 6;
var divs = $('.phone').get().sort(function(){
return Math.round(Math.random())-0.5;
}).slice(0,6);
$(divs).show();
});
但是这个脚本不起作用。哪里有问题?
*隐而不宣”工作*? – Liam