如图:

代码:

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. 【转载】php如何给APP端写接口

    如何写好接口 目的:清楚明白所写接口的用途 安全性:做好接口的安全性,防止接口数据泄露,做好必要的参数加密措施 按需分配: 接受值和返回值要实用,不接受和返回不需要的数据,返回值返回什么应与使用者时时 ...

  2. fatal error LNK1123: 转换到 COFF 期间失败:文件无效或损坏

    问题出现背景: 原本电脑里是装着VS2015的,其使用的是.NET 4.5,当再安装VS2010之后,不能与当前的.NET平台兼容.卸载VS2015时,不会恢复.NET 4.0. l 当VS2015安 ...

  3. create table like 和create table select 比较

    语法: CREATE [TEMPORARY] TABLE [IF NOT EXISTS] tbl_name     [(create_definition,...)]     [table_optio ...

  4. ui-router详解(二)ngRoute工具区别

    我们了解 angular.js 是一种富客户端单页面应用,所以要在一个页面呈现不同的视图,路由起到了至关重要的作用. angular.js 为我们封装好了一个路由工具 ngRoute ,它是一种靠ur ...

  5. s2sh框架整合具体配置-xml方式

    s2sh整合之xml方式 说明:本文档所採用的框架版本号为:Struts 2.1.8, Sping2.5.5,  Hibernate 3.5.6 1.    须要的jar包: ------------ ...

  6. atitit.研发管理--标准化流程总结---java开发环境与项目部署环境的搭建工具包总结

    atitit.研发管理--标准化流程总结---java开发环境与项目部署环境的搭建工具包总结 1. ide系列(只开发环境需要,但部署环境也做好放上,很有用) 1 2. web服务器+sdk+网站程序 ...

  7. C# 获得文件名

    string strFilePaht="文件路径"; Path.GetFileNameWithoutExtension(strFilePath);这个就是获取文件名的 还有的就是用 ...

  8. poj1936

    非连续子串匹配题,直接模拟 /** \brief poj 1936 * * \param date 2014/8/5 * \param state AC * \return memory 804k t ...

  9. 思科ACL不连续通配符掩码的计算

    access-list 120 permit ip 10.0.0.0 0.0.0.191 any     这条ACL看似简单,却又复杂,因为正常我们见到的通配符掩码都是诸如0.0.0.255(255. ...

  10. cocos2dx场景切换的坑

    有一个类可以使用不同的数据源,每个数据源对应一个对象. 我在类里保存了对象的实例,由于要在其它地方使用所以做成了静态,并在每次初始化时 重新设置,析构时删除. 现在我打开了A,切换到B,结果这个静态的 ...