onchange 와 onproperty change

인터넷 에서 돌 아 왔 는데 어디서 돌 았 는 지 모 르 겠 어 요.
하지만 실시 간 으로 사용자 의 입력 을 표시 합 니 다.
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 

<html xmlns="http://www.w3.org/1999/xhtml"> 

<head> 

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 

<title>on onpropertychange,oninput    onchange      by koyoz.com</title> 

<style type="text/css"> 

*{font-size:14px;font-family:'Comic Sans MS', Verdana} 

body {margin-left:20px} 

</style> 

</head> 



<body> 

<p>  onchange  : </p> 

<input type="text" id="txt1" /> 

<p>  onpropertychange/oninput  : </p> 

<input type="text" id="txt2" /> 

<p>  :</p> 

<input type="text" id="txt" /> 





<script type="text/javascript"> 

var $ = function(o) { 

return document.getElementById(o) 

}; 



$('txt1').onchange = function() { 

$('txt').value = this.value; 

} 



$('txt2').onpropertychange = function() { 

$('txt').value = this.value; 

} 



if (window.addEventListener) { 

$('txt2').addEventListener('input', function() {$('txt').value = this.value}, false); 

} 

</script> 

</body> 

</html>

좋은 웹페이지 즐겨찾기