日期:2014-05-16 浏览次数:20375 次
<a href="javascript:op(-1)">-</a><input value="1" type="text" id="txt" /><a href="javascript:op(1)">+</a> <script type="text/javascript"> function op(unit) { var txt = document.getElementById('txt'), v = txt.value; txt.value = parseInt(v, 10) + unit; } </script>
------解决方案--------------------
<script src="http://code.jquery.com/jquery-latest.js"></script> <script type="text/javascript"> function op(unit) { $("#txt").val(parseInt($("#txt").val())+unit); } </script>