码迷,mamicode.com
首页 > Web开发 > 详细

模仿淘宝上传图片之后在图片中单击按钮?

时间:2015-09-24 12:30:52      阅读:150      评论:0      收藏:0      [点我收藏+]

标签:

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Document</title>
<link rel="stylesheet" href="bootstrap.min.css">
<link rel="stylesheet" href="upload.css">
</head>
<body>
<ul class="upload inline-control" id="sortable">
    <li class="pic0">
        <img src="img/1.jpg" id="cart-0">
            <div class="operate">
                <i class="toleft">左移</i>
                <i class="toright">右移</i>
                <i class="del" data-id="0">删除</i>
            </div>
    </li>
    <li class="pic1">
        <img src="img/2.jpg" id="cart-1">
            <div class="operate">
                <i class="toleft">左移</i>
                <i class="toright">右移</i>
                <i class="del" data-id="1">删除</i>
            </div>
    </li>
    <li class="pic2">
        <img src="img/3.jpg" id="cart-2">
            <div class="operate">
                <i class="toleft">左移</i>
                <i class="toright">右移</i>
                <i class="del" data-id="2">删除</i>
            </div>
    </li>
    <li class="pic3">
        <img src="img/4.jpg" id="cart-3">
            <div class="operate">
                <i class="toleft">左移</i>
                <i class="toright">右移</i>
                <i class="del" data-id="3">删除</i>
            </div>        
    </li>
    <li class="pic4">
        <img src="img/5.jpg" id="cart-4">
            <div class="operate">
                <i class="toleft">左移</i>
                <i class="toright">右移</i>
                <i class="del" data-id="4">删除</i>
            </div>    
    </li>
  </ul>
<script src="js/jquery.min.js"></script>
<script src="js/jquery-ui.js"></script>

<script>
    
</script>
 <script>
      $(".toright").click(function(){
          var id=$(this).parent().parent().index();
              move(id,id+1);
      });
      $(".toleft").click(function(){
          var id=$(this).parent().parent().index();
              move(id,id-1);
       });
      $(".del").click(function(){
      $("#cart-"+$(this).data(id)).remove()
      });
        function move(from,to){
            if(to>4 || to<0) return;
            // $("div#view").html("<hr>"+from+"=>"+to+"<br>");
            var tmp=$("#cart-"+to).attr(src);
            var img=$("#cart-"+from).attr(src);
            $("#cart-"+to).attr(src,img);
            $("#cart-"+from).attr(src,tmp);
        }

   </script>
  <script>
  $(function() {
    $( "#sortable" ).sortable();
    $( "#sortable" ).disableSelection(); //拖动排序的序号怎么返回值是如何传给后台的?
  });
  </script>

  
</body>
</html>

 

模仿淘宝上传图片之后在图片中单击按钮?

标签:

原文地址:http://www.cnblogs.com/alone2015/p/4834581.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!