我想在bxslider中制作可更改的长度显示。首先,我确实选择了这个。
JS
var sure = $('ul > li > img').data("bekleme");
$(document).ready(function () {
$('.bxslider').bxSlider({
pager: false,
auto:true,
controls: false,
speed:sure
});
});
HTML
<ul class="bxslider">
<asp:Repeater ID="Repeater1" runat="server">
<ItemTemplate>
<li>
<img data-bekleme='<%# Eval("goruntulenmeSuresi") %>' src='/reklam/<%# Eval("yol") %>' />
</li>
</ItemTemplate>
</asp:Repeater>
</ul>
但它不起作用,任何人都可以帮助我吗?
答案 0 :(得分:0)
您是否尝试根据每张图片的bekleme值的总和来更改滑块的速度?
如果是这样,你必须循环遍历值并在文档加载后添加它们,但在设置bxSlider插件之前:
(文档)$。就绪(函数(){
var $sure = $('ul > li > img'),
iSpeed = 0;
//loop through images and sum values
$sure.each(function(index, element) {
//make sure there's a number value
var elementSpeed = ! isNaN($(element).attr("data-bekleme")) ? parseInt($(element).attr("data-bekleme")) : 0;
iSpeed += elementSpeed ? parseInt(elementSpeed) : 0;
});
$('.bxslider').bxSlider({
pager: false,
auto:true,
controls: false,
speed:iSpeed
});
});