<input type="text" name="textfield" id="text_input" /> <div>您输入的值为:<span id="test">还未输入</span></div> <script type="text/javascript"> function immediately(){ var element = document.getElementById("text_input"); if("\v"=="v") { //IE 6 7 8 element.onpropertychange = webChange; }else{ element.addEventListener("input",webChange,false); } function webChange(){ if(element.value){document.getElementById("test").innerHTML = element.value}; } } immediately(); </script>
时间: 2024-09-29 03:44:45