jquary实现点击小图实现大图的案例

今天的这个例子主要是实现点击小图能显示大图,来直接看代码:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<style>
    *{ margin:0; padding:0;}
    ul,li{list-style: none;}
    a{text-decoration: none;}
    .box{overflow: hidden;width:500px;margin:100px auto;}
    #sPic{overflow: hidden}
    #sPic li{width:100px;float:left;margin:10px;}
    #sPic li img{width:100px;height:auto;}
    #images{width:500px;}
    #des{text-align: center}
</style>
<body>
<div class="box">
    <ul id="sPic">
        <li><a href="javascript:void(0)" title="图片一"><img alt="图片一" src="img/pic1.jpg"/></a></li>
        <li><a href="javascript:void(0)" title="图片二"><img alt="图片二" src="img/pic2.jpg"/></a></li>
        <li><a href="javascript:void(0)" title="图片三"><img alt="图片三" src="img/pic3.jpg"/></a></li>
        <li><a href="javascript:void(0)" title="图片四"><img alt="图片四" src="img/pic4.jpg"/></a></li>
    </ul>
    <img id="images" src="img/pic1.jpg" width="500" alt=""/>
    <div id="des"></div>
</div>
<script src="js/jquery-1.11.3.min.js"></script>
<script>
    $(function(){
        $("#sPic  a img").click(function(){
            var src=$(this).attr("src");
            $("#images").attr("src",src);

            var title=$(this).attr("alt");
            $("#des").text(title);

        })
    })
</script>

</body>
</html>

效果图如下:

这个例子也只是简单的实现了点击小图呈现大图的效果,还有点击大图收回的效果也就是让其消失等等。希望这些对你有帮助把!

当然也希望有问题直接询问评论!

原文地址:https://www.cnblogs.com/web001/p/8343867.html

时间: 2024-07-29 13:57:13

jquary实现点击小图实现大图的案例的相关文章

仿淘宝点击小图出现大图效果

<div class="bigger"> <img src="images/bigger.png" alt="" id="pro_img" class="bigger" /> <script type="text/javascript" language="javascript"> function change_img(sourc

2018.7.6 js实现点击事件---点击小图出现大图---时间定时器----注册表单验证

<!DOCTYPE html> <html lang="zh"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <meta http-equiv="X-UA-Compatible"

移动端点击图片查看大图

一.需求 点击图片查看大图,再点大图隐藏.多用于移动端,因为移动端屏幕小,可能需要查看大图. 二.代码 <!DOCTYPE html> <html> <meta charset="utf-8"/> <head runat="server"> <title>JQuery点击图片查看大图by starof</title> <style type="text/css">

ionic中点击图片看大图的实现

在页面上显示了几张图片后,因为是手机端,图片会有点小的感觉,就想着怎么样才能让用户点击小图片看到大图呢,项目中ionic结合angularjs实现了这个功能 1.首先是三张小图上应添加一个函数,当点击图片时触发大图,代码如下: HTML: <div class="row padding"> <div class="col" style="width: 100px;height: 100px;padding:3px;-webkit-box-

JavaScript网站设计实践(五)编写photos.html页面,实现点击缩略图显示大图的效果

原文:JavaScript网站设计实践(五)编写photos.html页面,实现点击缩略图显示大图的效果 一.photos.html页面,点击每一张缩略图,就在占位符的位置那里,显示对应的大图. 看到的页面效果是这样的: 1.实现思路 这个功能在之前的JavaScript美术馆那里已经实现了. 首先在页面中使用ul列表显示出所有的缩略图,然后使用JavaScript,for循环检查出当前点击的是哪一张图片,最后把这张图片给显示出来. 用到三个函数:显示图片函数.创建占位符预装图片.点击显示图片

android开发:点击缩略图查看大图

android中点击缩略图查看大图的方法一般有两种,一种是想新浪微博list页面那样,弹出一个窗口显示大图(原activity为背景).另一种就是直接打开一个新的activity显示大图. 1.第一种方法我们可以使用自定义的AlertDialog来实现,代码如下: ImageView image=(ImageView)findViewById(R.id.small_image); image.setOnClickListener(new OnClickListener() { // 点击放大 p

每天一个JavaScript实例-点击图片显示大图添加鼠标操作

<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>每天一个JavaScript实例-点击图片显示大图添加鼠标操作</title> <style> img{padding:5px;width:100px;height:aut

每天一个JavaScript实例-点击图片显示大图

<!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>每天一个JavaScript实例-点击图片显示大图</title> <style> img{padding:5px;width:100px;height:auto;} #o

Web API---DOM---点击操作---节点的方式---案例

点击操作---节点的方式---案例 案例1:点击按钮,设置p变色---节点的方式做 <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>title</title> <style> div { width: 200px; height: 200px; border: 1px solid hotpin