zoukankan      html  css  js  c++  java
  • js实现上传图片预览,购物车加减

    js效果(一):上传的图片预览

    $("#path").change(function(){
      var objUrl = getObjectURL(this.files[0]) ;
      console.log("objUrl = "+objUrl) ;
      if (objUrl) {
        $("#img0").attr("src", objUrl) ;
      }
    }) ;
    //建立一個可存取到該file的url
    function getObjectURL(file) {
      var url = null ; 
      if (window.createObjectURL!=undefined) { // basic
        url = window.createObjectURL(file) ;
      } else if (window.URL!=undefined) { // mozilla(firefox)
        url = window.URL.createObjectURL(file) ;
      } else if (window.webkitURL!=undefined) { // webkit or chrome
        url = window.webkitURL.createObjectURL(file) ;
      }
      return url ;
    }
    <img src="images/head_int_03.gif" id="img0">
    <input type="file" id="path" &nbsp;name="path" style="display:none" onchange="upfile.value=this.value" multiple="multiple">

    购物车加减功能:

    <script>
            $(function(){
                $(".add").click(function(){
                    var t = $(this).parent().find(".text_box");
                    t.val(parseInt(t.val())+1)
                    setTotal();
                })
                $(".min").click(function(){
                    var t = $(this).parent().find(".text_box")
                    t.val(parseInt(t.val())-1)
                    setTotal();
                })
                function setTotal(){
                    $("#total").html((parseInt(t.val())*3.95).toFixed(2));
                }
                setTotal();
            })
        </script>
  • 相关阅读:
    java分页查询--oracle
    Tomcat Excel中的数据导出到页面中显示
    接口调用类3
    接口工具类2
    接口工具类
    redis 对外访问
    Spring 项目启动时执行
    scp 本地上传/下载服务器文件
    CentOS 安装 rabbitMQ
    卸载rabbitMQ
  • 原文地址:https://www.cnblogs.com/sakura-Master/p/4054165.html
Copyright © 2011-2022 走看看