<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>获取键入值的Unicode编码值</title> <!--引入css样式--> <link rel="stylesheet" type="text/css" href="themes/default/easyui.css"> <link rel="stylesheet" type="text/css" href="themes/icon.css"> <!--引入js样式有顺序--> <script type="text/javascript" src="js/jquery.min.js"></script> <script type="text/javascript" src="js/jquery.easyui.min.js"></script> <script type="text/javascript" src="js/easyui-lang-zh_CN.js"></script> </head> <body> 时间:<input id="ss" style="width:80px;"> <script> $(‘#ss‘).numberspinner({ min: 1, max: 100, value:1 }); </script> <p></p> 你一共买了<span id="qq">1</span>件商品 <script> $(‘#ss‘).keyup(function(xxx){ //传入键入值 var event=xxx; //获取键入值得Unicode编码 var code=event.keyCode; //将编码显示出来 alert(code); if(code==13){ var ss=$(this).val(); var qq=$("#qq").text(ss).css("color","red"); } }); </script> </body> </html>
时间: 2024-10-14 07:17:50