日期:2014-05-16 浏览次数:20482 次
<div class="box"> <input type="text" id="showValue" class="text" /> <table class="table"> <tr> <td><input type="button" class="d0btn" value="退格" /></td> <td><input type="button" class="d0btn" value="清屏"/></td> <td><input type="button" class="d1btn" value="sqrt"/></td> <td><input type="button" class="d2btn" value="÷"/></td> </tr> <tr> <td><input type="button" class="d3btn" value="7" /></td> <td><input type="button" class="d3btn" value="8" /></td> <td><input type="button" class="d3btn" value="9"/></td> <td><input type="button" class="d2btn" value="×"/></td> </tr> <tr> <td><input type="button" class="d3btn" value="4"/></td> <td><input type="button" class="d3btn" value="5"/></td> <td><input type="button" class="d3btn" value="6"/></td> <td><input type="button" class="d2btn" value="-"/></td> </tr> <tr> <td><input type="button" class="d3btn" value="1"/></td> <td><input type="button" class="d3btn" value="2"/></td> <td><input type="button" class="d3btn" value="3"/></td> <td><input type="button" class="d2btn" value="+"/></td> </tr> <tr> <td><input type="button" class="d3btn" value="0"/></td> <td><input type="button" class="d3btn" value="."/></td> <td><input type="button" class="d3btn" value="+/-"/></td> <td><input type="button" class="d4btn" value="="/></td> </tr> </table> </div>
var firstValue = ""; $(function () { $("input:not(#showValue)").mousedown(function () { $(this).attr({ style: "background-position:0px 0px" }).mouseup(function () { $(this).attr({ style: "background-position:0px -44px" }); }).click(function () { if (this.className == "d3btn") { firstValue = this.value.toString(); alert(firstValue); } }); }); });