我在我的网站上添加了一个 Jquery 滑块(称为 SudoSlider),带有“上一张”和“下一张”按钮,允许用户前进到下一张幻灯片,或返回一张。但是,我想使幻灯片自动更改。
我遇到了与此类似的问题,但我的 Javascript 相当有限,因此我无法使用提供给其他用户的代码。
如果有人可以帮助我实现这一目标,我将不胜感激。
请在此处查看此JSFiddle以了解使用的代码。
此外,如果 JSFiddle 没有用,滑块可以在此处看到。
首先十分感谢!
这是工作小提琴:http: //jsfiddle.net/surendraVsingh/VN7F8/1/
我只是更改了加载 javascript 的顺序。以下是包含 javascript 的完整 HTML 并包含您拥有的外部 css。
HTML 更改:
<html>
<head>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"/></script>
<script type="text/javascript" src="http://www.pinknoise-systems.co.uk/userfiles/jquery/slider/js/jquery.sudoSlider.min.js"/></script>
<script type="text/javascript">
$(document).ready(function(){
var sudoSlider = $("#slider").sudoSlider();
});
</script>
</head>
<body>
<div id="container">
<div style="position:relative;">
<div id="slider">
<ul>
<li>
<div style="margin:0 auto;text-align:center;height:300px;">
<img src="http://www.pinknoise-systems.co.uk/userfiles/images/final_slide_6.png" />
</div>
</li>
<li>
<div style="margin:0 auto;width:620px;height:300px;background:url('http://www.pinknoise-systems.co.uk/userfiles/images/final_slide_5.png');">
<div class="product_row_1">
<div class="one">
<a href="http://www.pinknoise-systems.co.uk/Sennheiser_SKP_300_G3--product--1091.html" class="slide_product_name">Sennheiser SKP 300 G3</a>
<div class="p-image"><a href="http://www.pinknoise-systems.co.uk/Sennheiser_SKP_300_G3--product--1091.html"><img src="http://www.pinknoise-systems.co.uk/userfiles/images/monthly/skp300.jpg" /></a></div>
<div class="p-content">
<img src="http://www.pinknoise-systems.co.uk/userfiles/images/monthly/4_stars.png" />
<p class="slide_product_price">£296.00</p>
<p class="slide_product_price2">EX VAT @20%</p>
</div>
</div>
<div class="two margin-3">
<a href="http://www.pinknoise-systems.co.uk/Fostex_PM841_Professional_Studio_Monitor--product--1110.html" class="slide_product_name">Fostex PM8.4.1</a>
<div class="p-image"><a href="href="http://www.pinknoise-systems.co.uk/Fostex_PM841_Professional_Studio_Monitor--product--1110.html""><img src="http://www.pinknoise-systems.co.uk/userfiles/images/monthly/pm841.jpg" /></a></div>
<div class="p-content">
<img src="http://www.pinknoise-systems.co.uk/userfiles/images/monthly/4_stars.png" />
<p class="slide_product_price">£412.50</p>
<p class="slide_product_price2">EX VAT @20%</p>
</div>
</div>
<div class="three margin-3">
<a href="http://www.pinknoise-systems.co.uk/Delkin_Wingman_HD_3oz_Waterproof_Action_Camera--product--850.html" class="slide_product_name">Delkin Wingman</a>
<div class="p-image"><a href="http://www.pinknoise-systems.co.uk/Delkin_Wingman_HD_3oz_Waterproof_Action_Camera--product--850.html"><img src="http://www.pinknoise-systems.co.uk/userfiles/images/monthly/wingman.jpg" /></a></div>
<div class="p-content">
<div class="4stars"><img src="http://www.pinknoise-systems.co.uk/userfiles/images/monthly/4_stars.png" /></div>
<p class="slide_product_price">£179.19</p>
<p class="slide_product_price2">EX VAT @20%</p>
</div>
</div>
</div>
<div class="product_row_2">
<div class="one">
<a href="http://www.pinknoise-systems.co.uk/DFocus_Street_Runner_Bundle--product--1104.html" class="slide_product_name">D|Focus Street Runner Kit</a>
<div class="p-image"><a href="http://www.pinknoise-systems.co.uk/DFocus_Street_Runner_Bundle--product--1104.html"><img src="http://www.pinknoise-systems.co.uk/userfiles/images/monthly/streetrunnerbundle.jpg" /></a></div>
<div class="p-content">
<div class="4stars"><img src="http://www.pinknoise-systems.co.uk/userfiles/images/monthly/4_stars.png" /></div>
<p class="slide_product_price">£332.50</p>
<p class="slide_product_price2">EX VAT @20%</p>
</div>
</div>
<div class="two margin-3">
<a href="http://www.pinknoise-systems.co.uk/DFocus_Field_Runner_Bundle--product--1105.html" class="slide_product_name">D|Focus Field Runner Kit</a>
<div class="p-image"><a href="http://www.pinknoise-systems.co.uk/DFocus_Field_Runner_Bundle--product--1105.html"><img src="http://www.pinknoise-systems.co.uk/userfiles/images/monthly/fieldrunnerkit.jpg" /></a></div>
<div class="p-content">
<div class="4stars"><img src="http://www.pinknoise-systems.co.uk/userfiles/images/monthly/4_stars.png" /></div>
<p class="slide_product_price">£382.50</p>
<p class="slide_product_price2">EX VAT @20%</p>
</div>
</div>
<div class="three margin-3">
<a href="http://www.pinknoise-systems.co.uk/DFocus_Austin_Rig_Bundle--product--1106.html" class="slide_product_name">D|Focus Austin Rig Bundle</a>
<div class="p-image"><a href="http://www.pinknoise-systems.co.uk/DFocus_Austin_Rig_Bundle--product--1106.html"><img src="http://www.pinknoise-systems.co.uk/userfiles/images/monthly/austinrigbundle.jpg" /></a></div>
<div class="p-content">
<img src="http://www.pinknoise-systems.co.uk/userfiles/images/monthly/4_stars.png" />
<p class="slide_product_price">£499.17</p>
<p class="slide_product_price2">EX VAT @20%</p>
</div>
</div>
</div>
</div>
</li>
<li>
<div style="margin:0 auto;text-align:center;">
<img src="http://www.pinknoise-systems.co.uk/userfiles/images/final_slide_3.jpg" />
</div>
</li>
<li>
<div style="margin:0 auto;text-align:center;">
<img src="http://www.pinknoise-systems.co.uk/userfiles/images/final_slide_4.jpg" />
</div>
</li>
</ul>
</div>
</div>
</div>
</body>
</html>
</p>
试试这个,它将滑块设置为自动更改。
$(document).ready(function(){
var sudoSlider = $("#slider").sudoSlider({fade: true,auto:true});
});
这是工作链接