我正在一个客户网站上工作,希望"cruise_offers“目录上的背景图像发生变化,可能只有3-4个图像在旋转。
我的jquery知识非常基础,所以任何帮助都会很好。
我更喜欢它与jQuery一起工作,因为我在网站的其他地方使用它。
我的标记:
<div class="cruise_offers">
<span class="overlay_bar">
<a href="cruiseoffers.html">View our Great Cruise Offers</a>
</span>
</div>干杯
罗里
发布于 2010-02-06 02:56:53
发布于 2010-02-06 03:07:24
$(div.cruise_offers).removeClass('cruise_offers');
$(div.cruise_offers).addClass('cruise_offers1');在css中使用不同的背景图像创建类。
发布于 2010-02-06 03:10:27
也许像这样的东西可以工作(我还没有测试过它)。
var current_image = 0;
var rotation_speed = 5000; //milliseconds
var where = $("div.cruise_offers");
var images = new Array();
images[0] = 'img1.jpg';
images[1] = 'img2.jpg';
function change_image() {
current_image++;
if (images[current_image].length == 0) {
current_image = 0;
}
$(where).css("background-image", "url("+images[current_image]+")")
}
if (where.length != 0) {
setTimeout("change_image()", rotation_speed);
}https://stackoverflow.com/questions/2209565
复制相似问题