I want to alert different word base on different actions, but it doesn't work.
this is my code:
<input id=main value="ddddd">
<script type="text/javascript">
var obj = document.getElementById("main");
var items = [ "click", "keypress" ];
for ( var i = 0; i < items.length; i++ ) {
obj[ "on" + items[i] ] = function() {
alert( "Thanks for your " + items[i] );
};
}
</script>