私は自分のウェブサイトにスライダーを持っていて、その中にランダムな写真を表示したいと思います。私の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();
});
しかし、このスクリプトは動作しません。問題はどこだ?
を見ることができるようにあなたのスクリプトが作業を行う* doesnの」仕事*? – Liam