这段代码怎么改写成jquery
functioninputkey(key){varindex=key.charCodeAt(0);if((carry==2&&(index==48||index==49)...
function inputkey(key)
{
var index=key.charCodeAt(0);
if ((carry==2 && (index==48 || index==49))
|| (carry==8 && index>=48 && index<=55)
|| (carry==10 && (index>=48 && index<=57 || index==46))
|| (carry==16 && ((index>=48 && index<=57) || (index>=97 && index<=102))))
if(endNumber)
{
endNumber=false
document.calc.display.value = key
}
else if(document.calc.display.value == null || document.calc.display.value == "0")
document.calc.display.value = key
else
document.calc.display.value += key
}
<INPUT onClick="inputkey('1')" style="COLOR: #1919CD; font-size:16px; line-height:24px;" type=button value=" 1 "> 展开
{
var index=key.charCodeAt(0);
if ((carry==2 && (index==48 || index==49))
|| (carry==8 && index>=48 && index<=55)
|| (carry==10 && (index>=48 && index<=57 || index==46))
|| (carry==16 && ((index>=48 && index<=57) || (index>=97 && index<=102))))
if(endNumber)
{
endNumber=false
document.calc.display.value = key
}
else if(document.calc.display.value == null || document.calc.display.value == "0")
document.calc.display.value = key
else
document.calc.display.value += key
}
<INPUT onClick="inputkey('1')" style="COLOR: #1919CD; font-size:16px; line-height:24px;" type=button value=" 1 "> 展开
展开全部
<!DOCTYPE HTML>
<html lang="en-US">
<head>
<meta charset="UTF-8">
<title>main.html</title>
<style type="text/css">
</style>
<script type="text/javascript" src="jquery-1.8.0.min.js"></script>
<script type="text/javascript">
var carry = 2, endNumber = true, index = 48;
jQuery (function ($)
{
var form = $('form[name="calc"]'),
fb = form.children (':button'),
ft = form.children(':text[name="display"]');
fb.click ( fb.val(), function (e)
{
var key = e.data;
var index = key.charCodeAt (0);
if (
(carry == 2 && (index == 48 || index == 49))
|| (carry == 8 && index >= 48 && index <= 55)
|| (carry == 10 && (index >= 48 && index <= 57 || index == 46))
|| (carry == 16 && ((index >= 48 && index <= 57) || (index >= 97 && index <= 102)))
)
{
if (endNumber)
{
endNumber = false;
ft.val (key);
}
else if (!ft.val ())
{
ft.val (key);
}
else
{
ft.val (ft.val () + key);
}
}
});
});
</script>
</head>
<body>
<form name="calc">
<input type="text" name="display" />
<input
style="color: #1919CD; width:90px; height: 35px; font-size: 16px;"
type=button
value="1" />
</form>
</body>
</html>
追问
function (e)这个E从哪儿进去的啊
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询