解决方案 »

  1.   

    <html>
    <head>
    <title>test</title>
    <meta charset="utf-8" />
    </head>
    <style>
    .content{
    width:100px;
    height:40px;
    margin-bottom:5px;
    border:1px solid #ccc;
    }
    input{
    width:30px;
    height:30px;
    float:left;
    }
    </style>
    <body>
    <div class="content">
    <input type="button" name="" value="-" />
    <input type="button" name="" value="0" />
    <input type="button" name="" value="+" />
    </div><div class="content">
    <input type="button" name="" value="-" />
    <input type="button" name="" value="0" />
    <input type="button" name="" value="+" />
    </div>
    <div class="content">
    <input type="button" name="" value="-" />
    <input type="button" name="" value="0" />
    <input type="button" name="" value="+" />
    </div>
    <script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.4.2.min.js"></script>
    <script>
        var o;
        $(':button').click(function () {
            switch (this.value) {
                case '-': o = $(this).next(); o.val(parseInt(o.val(), 10) - 1); break;
                case '+': o = $(this).prev(); o.val(parseInt(o.val(), 10) + 1); break;
            }
        });
    </script>
    </body>
    </html>