JavaScript事件的3種寫法~
很基本, 但我卻每次都會忘記, 寫下來備忘一下:
寫法1:
In HTML:
<element onkeyup="myScript">
寫法2:
In JavaScript:
object.onkeyup=function(){myScript};
寫法3:
In JavaScript, using the addEventListener() method:
object.addEventListener("keyup", myScript);
--> 注意: The addEventListener() method is not supported in Internet Explorer 8 and earlier versions.
寫法1:
In HTML:
<element onkeyup="myScript">
寫法2:
In JavaScript:
object.onkeyup=function(){myScript};
寫法3:
In JavaScript, using the addEventListener() method:
object.addEventListener("keyup", myScript);
--> 注意: The addEventListener() method is not supported in Internet Explorer 8 and earlier versions.
留言
張貼留言