如图:

代码:

html

@*商品主图片*@
<div class="product-img" style="display:table-cell;width:400px;border:1px solid #aaa;text-align:center">
  <img width="500" height="400" src="/upload/store/@ViewBag.StoreId/product/show/thumb350_350/@ViewBag.ProductImg"/>
</div> @*商品所有图片*@
<div class="product-img-all" style="margin-top:15px;width:400px">
  <div class="product-img-prev" style="float:left;width:30px;height:62px;text-align:center;line-height:62px;color:#fff;font-size:25px;background-  color:#ccc"><</div>
  <ul style="display:inline-block;height:60px">
    @foreach (ProductImage item in ViewBag.ProductImages)
    {
      <li name ="list" style="display:inline-block;border:1px solid #bce8f1">
        <img src="/upload/store/@ViewBag.StoreId/product/show/thumb60_60/@item.showimg" />
        <input type="hidden" value="@item.showimg"/>
      </li>
    }
  </ul>
  <div class="product-img-next" style="float:right;width:30px;height:62px;text-align:center;line-height:62px;color:#fff;font-size:25px;background  -color:#ccc">></div>
</div>

js

$(document).ready(function () {
//商品主图边框为深色
$(".product-img-all").find("li").eq(0).css({ "border": "1px solid #6581ee" }); //商品所有图片点击事件
$(".product-img-all").find("li").click(function () {
$(this).css({ "border": "1px solid #6581ee" });
$(this).prevAll("li").css({ "border": "1px solid #bce8f1" });
$(this).nextAll("li").css({ "border": "1px solid #bce8f1" });
var img = $(this).find("input").val();
getProductImg(img);
}); //上一张商品图
$(".product-img-prev").mousedown(function () {
$(this).css({ "backgroundColor": "#aaa" });
}).mouseup(function () {
$(this).css({ "backgroundColor": "#ccc" });
var img = $(".product-img-all").find("li");
img.each(function (index) {
var b = $(this).css("border");
//index会为0
if (b.indexOf("101, 129, 238") != -1 && index != 0) {
$(this).css({ "border": "1px solid #bce8f1" }); //浅色
$(this).prev("li").css({ "border": "1px solid #6581ee" }); //深色 var i = $(this).prev("li").find("input").val();
getProductImg(i);
}
});
}); //下一张商品图
$(".product-img-next").mousedown(function () {
$(this).css({ "backgroundColor": "#aaa" });
}).mouseup(function () {
$(this).css({ "backgroundColor": "#ccc" });
var img = $(".product-img-all").find("li");
img.each(function (index) {
//index从0开始
if ((index + 1) == img.length) {
return false;
}; var b = $(this).css("border");
//index会为0
if (b.indexOf("101, 129, 238") != -1) {
$(this).css({ "border": "1px solid #bce8f1" }); //浅色
$(this).next("li").css({ "border": "1px solid #6581ee" }); //深色 var i = $(this).next("li").find("input").val();
getProductImg(i);
return false; //跳出遍历
}
});
}); }); //设置商品大图
function getProductImg(img) {
$(".product-img").find("img").attr("src", "/upload/store/" + getParameter("storeId") + "/product/show/thumb350_350/" + img);
} //获取Url地址中的参数
function getParameter(name) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)");
var r = window.location.search.substr(1).match(reg);
if (r != null) return unescape(r[2]); return null;
}

JQuery------实现点击左右按钮,切换图片功能的更多相关文章

  1. JQuery实现点击按钮切换图片(附源码)--JQuery基础

    JQuery实现切换图片相对比较简单,直接贴代码了哈,有注释噢!疑问请追加评论哈,不足之处还请大佬们指出! 1.案例代码: demo.html: <!DOCTYPE html><ht ...

  2. 用 JS 点击左右按钮 使图片切换 - 最精简版-ljx2380000-ChinaUnix博客

    body { font-family: "Microsoft YaHei UI","Microsoft YaHei",SimSun,"Segoe UI ...

  3. 使用jQuery实现点击左右滑动切换特效

    使用jQuery实现点击左右滑动切换特效: HTML代码如下: <!--整体背景div--> <div class="warp"> <!--中间内容d ...

  4. jQuery实现的鼠标滑过切换图片代码实例

    jQuery实现的鼠标滑过切换图片代码实例:有时候网页需要这样的简单效果,那就是当鼠标滑过默认图片的时候,能够实现图片的切换,可能在实际应用中,往往没有这么简单,不过大家可以自行扩展一下,下面简单介绍 ...

  5. JQuery移动动画实现点击按钮切换图片--JQuery基础

    直接贴源码了哈,这些都是自己总结的……汗水几何?希望能帮到大家. <%@ Page Language="C#" AutoEventWireup="true" ...

  6. 原生js点击按钮切换图片

    <!DOCTYPE html><html lang="en"><head> <meta charset="UTF-8" ...

  7. 炫酷实用的jQuery插件 涵盖菜单、按钮、图片

    新的一周开始了,今天我们要为大家分享一些全新的jQuery插件和HTML5/CSS3应用,这些jQuery插件不仅非常炫酷,而且还挺实用,这次的分享包含jQuery菜单.CSS3按钮已经多种图片特效, ...

  8. Axure初体验:简单交互、通过按钮切换图片

    前言: 之前是一直用processon的UI原型设计,后来感觉只能完成静态页面的processon满足不了原型设计的需求,断网时候也不方便修改.展示.最终还是决定学习动态页面的制作,所选工具为原型设计 ...

  9. jQuery演示10种不同的切换图片列表动画效果

    经常用到的图片插件演示jQuery十种不同的切换图片列表动画效果 在线演示 下载地址 实例代码 <!DOCTYPE html> <html lang="en" c ...

  10. jQuery演示10种不同的切换图片列表动画效果以及tab动画演示 2

    很常用的一款特效纯CSS完成tab实现5种不同切换对应内容效果 实例预览 下载地址 实例代码 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 ...

随机推荐

  1. mysql索引二

    理解MySQL——索引与优化 写在前面:索引对查询的速度有着至关重要的影响,理解索引也是进行数据库性能调优 的起点.考虑如下情况,假设数据库中一个表有10^6条记录,DBMS的页面大小为4K,并存储1 ...

  2. 对象的序列化存储:Serializable 和 Parceable

    在进行Android开发的时候我们有时候需要用到数据的持久化存储,或者在进程之间传递数据.其中就可能需要用到对象的序列化,经过序列化的对象之后可以通过Intent或者Boundle来传输了.接下来还是 ...

  3. 使用URLConnection下载文件或图片并保存到本地

    有时候需要从网络上面下载图片到本地进行保存,代码如下: package com.jointsky.jointframe.test; import java.io.FileOutputStream; i ...

  4. python __path__ 变量

    今天在读django源码的时候遇到了一个问题!它就是__path__这个系统变量 一.__path__变更初见: 由__path__这个变量的名字就知道,这个是一个系统变量,不是用户自定义的变量,于是 ...

  5. ubuntu内窗口最大最小化

    我用的dell笔记本,开始的时候,需要修改dell笔记本的BIOS,里面有一个 Funtion Key 一开始定义的行为是多媒体的,需要改成默认行为,具体记不清了, 反正知道这个,肯定知道哪里找. 然 ...

  6. 【LeetCode】Permutations II 解题报告

    [题目] Given a collection of numbers that might contain duplicates, return all possible unique permuta ...

  7. ognl概念和原理详解

    一.问题的提出   在mvc中,数据是在各个层次之间进行流转是一个不争的事实.而这种流转,也就会面临一些困境,这些困境,是由于数据在不同世界中的表现形式不同而造成的: 1. 数据在页面上是一个扁平的, ...

  8. table中添加下拉框

    { file: 'usename', title: '下发用户', width:"20%", align: 'center', templet: function (d) { va ...

  9. Windows操作系统下 使用c++ WIN32API禁用控制台最小化和关闭按钮

    #include<Windows.h> //屏蔽控制台最小按钮和关闭按钮 HWND hwnd = GetConsoleWindow(); HMENU hmenu = GetSystemMe ...

  10. django如何给上传的图片重命名(给上传文件重命名)

    1.先在你项目中添加一个文件夹如:system 在文件夹下添加__init__.py 和storage.py文件,并在storage.py中添加如下代码: # -*- coding: UTF-8 -* ...