1. 程式人生 > >js 文字框鍵盤輸入事件

js 文字框鍵盤輸入事件

html

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <title></title>
    <link href="../Content/StyleSheet7.css" rel="stylesheet" />
    <script src="../Scripts/cxc.js"></script>
    <script src="../Scripts/JavaScript7.js"></script>
	<meta charset="utf-8" />
</head>
<body>
    <ul>
        <li><input type="text" id="txt" /></li>
        <li id="show"></li>
    </ul>
    
</body>
</html>
js
window.onload = function () {
    AddEvent($("txt"), EventsType1[0], fun1);
};
var fun1 = function () {
    AddEvent(document, EventsType2[0], fun2);
};
var fun2 = function () {
    setTimeout(function () { $("show").innerHTML = $("txt").value; },1); 
};

css