zoukankan      html  css  js  c++  java
  • 购物时添加数量

     

    购物数量添加:

    <!DOCTYPE html>
    <html>
        <head>
            <meta charset="UTF-8">
            <title></title>
            <style>
                body{
                    margin: 0;
                }
                .left{
                    float: left;
                }
                .wrap{
                     150px;
                    height: 22px;
                    border: 1px solid #ddd;
                    /*background-color: red;*/
                    position: relative;
                    left: 100px;
                    top: 100px;
                }
                .wrap .minus{
                    height: 22px;
                     22px;
                    line-height: 22px;
                    text-align: center;
                    cursor: pointer;
                }
                .wrap .plus{
                    height: 22px;
                     22px;
                    line-height: 22px;
                    text-align: center;
                    cursor: pointer; /*当鼠标指的时候变样式*/
                }
                .wrap .count input{
                    padding: 0;  /*input是有padding的*/
                    border: 0;
                     104px;
                    height: 22px;
                    border-left: 1px solid #dddddd;
                    border-right: 1px solid #dddddd;
                }
            </style>
        </head>
        <body>
            <div class="wrap">
                <div class="minus left" onclick='Minus();'>-</div>
                <div class="count left">
                    <input id='count' type="text"  />
                </div>
                <div class="plus left" onclick='Plus();'>+</div>
            </div>
            <script type="text/javascript">
                function Plus(){
                    var old_str = document.getElementById('count').value
                    var old_int = parseInt(old_str);
                    var new_int = old_int + 1
                    document.getElementById('count').value = new_int
                }
                function Minus(){
                    var old_str = document.getElementById('count').value
                    var old_int = parseInt(old_str);
                    var new_int = old_int - 1
                    document.getElementById('count').value = new_int
                }
    
            </script>
        </body>
    </html>
    
    
    cursor:pointer;  /*鼠标尖头变小手*/
    View Code
  • 相关阅读:
    华东交通大学2017年ACM双基程序设计大赛题解
    hdu2010(dfs+剪枝)
    欧拉函数phic以及超大数的快速幂
    想了一天的题目QAQ 毛线数列的最值
    记一下STL的一个题
    hdu1877进制转换
    hdu1002大数相加
    hdu1576逆元的一道水题
    Courses
    CodeForce-813B The Golden Age(数学+枚举)
  • 原文地址:https://www.cnblogs.com/wuyongcong/p/5643111.html
Copyright © 2011-2022 走看看