jquery效果----向左移、向右移

<script type="text/javascript" charset="utf-8">


    
    // tab 切换
    var tabIt = $('#tab-it');
    var tabItA = tabIt.find('a')
    var tabContents = $('div.product-msgcontent');

$(function(){
    

    tabItA.click(function(e){
        e.preventDefault();
        tabItA.removeClass('curr');
        $(this).addClass('curr')
        tabContents.hide();
        $('#' + $(this).attr('data-target')).show();
    });


    $(".changeImg").eq(0).show();

    $("#buyNum").keyup(function(){
    //判断数量是否大于库存  

    if($(this).val() > {$flower['storage']}){
      $(this).val({$flower['storage']})
    }
    //判断数量是否小于1
    if($(this).val()<1){
      $(this).val(1);
    }
    //判断数量是否是整数
    if($(this).val()%1 != 0){
      $(this).val(parseInt($(this).val()));
    }
    //钱数显示保存后两位
    var price = $(this).val()*{$flower['price']};
    if(price %1 == 0){
      price += ".00";
    }else if(price *10%1 == 0){
      price += "0";
    }
    $("#totalPrice").html(price)
    $("input[name='price']").val(price);
  })

   $(".cutright").click(function(){
        // 图片总数
        var objNum = $("#imgUl li").length;
        // 获取选中的索引
       var selectedIndex = $('#imgUl li').index($("#imgUl .curr").parent());
       
       
       
        if (selectedIndex == objNum-1) {
          return false;
        }
        // 下一个图片高亮
        $("#imgUl li a").removeClass("curr").eq(selectedIndex+1).addClass("curr");
        // 显示下一个的大图
      $(".tomb-bigshow img").css('display', "none").eq(selectedIndex+1).css('display', "");

    

      if (selectedIndex >= 3) {
      if ($("#imgUl").css('marginLeft') == '-'+((objNum-4)*65)+'px') {
        return false;
      }
          $("#imgUl").animate({ marginLeft:"-=65px" }, 0, function(){});
      }
      });

      // 向左滚动
     
      $(".cutleft").click(function(){
          // 图片总数
          var objNum = $("#imgUl li").length;
          // 获取选中的索引
          var selectedIndex = $('#imgUl li').index($("#imgUl .curr").parent());
          if (selectedIndex == 0) {
            return false;
          }
          // 上一个图片高亮
          $("#imgUl li a").removeClass("curr").eq(selectedIndex-1).addClass("curr");
          // 显示上一个的大图
          $(".tomb-bigshow img").css('display', "none").eq(selectedIndex-1).css('display', "");
          if (objNum - selectedIndex <= 4) {
            if ($("#imgUl").css('marginLeft') == '0px') {
              return false;
            }
            $("#imgUl").animate({ marginLeft:"+=65px" }, 0, function(){  });
          }
      });

      // 图片移动去的效果
      
      $("#imgUl a").mouseover(function(){
        $(this).addClass("curr").parent().siblings().children("a").removeClass("curr");
        // 获取选中的索引
          var selectedIndex = $('#imgUl li').index($(this).parent());
          // 显示下一个的大图
          $(".tomb-bigshow img").css('display', "none").eq(selectedIndex).css('display', "");
      });

      //添加购物车
      $(".addShop").click(function(){
      var id = $(this).next().val();
      var price = $(this).next().next().val();
      $.post("/goods/addShop",{"id":id,"type":"shop","price":price},function(e){
      
        if(e == 1){
          alert("添加成功");
        }else if (e == 2){
          alert("商品库存不足");
        }else{
          alert("商品已存在");
        }
      })
    })
    $(".favadd").click(function(){
            var id = $(this).attr("value");
            $.post("/Goods/addFav",{"id":id,"type":"goods"},function(e){
                if(e == 1){
                    alert("收藏成功");
                    $(".totalFav").html(parseInt($(".totalFav").html())+1);
                }else{
                    alert("已经收藏");
                }
            })
        })

})
//详情页相册效果

// 向右滚动
   
</script>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值