这是您的演示
这是使其工作的 Jquery 代码片段。请注意,我已使用随机图像进行演示。你可以使用你的:)
$(document).ready(function () {
var images = [{
"image": "http://cdn.arstechnica.net/wp-content/uploads/2012/10/02_Place_Piorkowski.jpg","Text": "text 1 for slide"
}, {
"image": "http://cdn.arstechnica.net/wp-content/uploads/2012/10/03_Place_Burnette.jpg", "Text": "text 2 for slide"
}, {
"image": "http://cdn.arstechnica.net/wp-content/uploads/2012/10/04_Place_21756_1_Williamson.jpg","Text": "text 3 for slide"
}, {
"image": "http://cdn.arstechnica.net/wp-content/uploads/2012/10/09_Place_22047_3_Drange.jpg", "Text": "text 4 for slide"
}];
$(".slide_img").data("imageShown", 0);
$(".slide_img").css("background-image", "url(" + images[0].image + ")");
$("p.df").html(images[0].Text);
$("input[value='Finish']").click(function () {
$(".slide_img").hide();
$("p.df").hide();
});
$("input[value='Next']").click(function () {
var id = $(".slide_img").data("imageShown");
if (id == (images.length - 1)) {
return;
}
id = id + 1;
$(".slide_img").data("imageShown", id);
$(".slide_img").css("background-image", "url(" + images[id].image + ")");
$("p.df").html(images[id].Text);
});
$("input[value='Previous']").click(function () {
var id = $(".slide_img").data("imageShown");
if (id == 0) {
return;
}
id = id - 1;
$(".slide_img").data("imageShown", id);
$(".slide_img").css("background-image", "url(" + images[id].image + ")");
$("p.df").html(images[id].Text);
});
});