使用JQuery通过鼠标单击更改图像

时间:2012-09-30 15:10:06

标签: jquery

我正在尝试制作图片幻灯片。我没有Jquery的经验,我需要一些帮助。所以基本上我在div#幻灯片中有一个图像。我希望在那里放置多个图像并使用Jquery的强大功能,当用户单击左/右按钮时,它将更改为下一个图像。这是我的HTML部分代码 -

<!DOCTYPE html>
<html lang="en">
<head>
<link href='http://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css'>
<style>
body {
background: url(bg.png);
width: 999px;
font-family: 'Open Sans', sans-serif;
margin: 0 auto;
}
p {
color: #222;
}
a {
color: #777;
font-size: 14px;
font-weight: bold;
text-decoration: none;
padding: 10px;
}
#nav {
float: right;
}
#slideshow {
width: 999px;
margin: 100px -50px;
}
#content {
background: #FFF;
padding: 50px;
height: 500px;
border-radius: 1px;
margin: 50px auto;
}
</style>
</head>
<body>
<div id="content">
<div id="nav">
<a href="..">Home</a>
<a href="..">About</a>
<a href="..">Work</a>
<a href="..">Contact</a>
</div>
<div id="slideshow">
<img src="image.jpg" />
</div>
</div>
</body>
</html>

1 个答案:

答案 0 :(得分:2)

查看jQuery的SlidesJS插件。以下是示例页面:http://www.slidesjs.com/#examples

有很多插件可以执行此操作(例如ResponsiveSlides),但这个插件非常简单,您应该能够解决这个问题。