1
我想通過不同的動作提示不同的詞,但它不起作用。無法將參數傳遞給循環
這是我的代碼:
<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>