帮帮忙,看看这段代码哪里有错???
var obj =document.getElementById("main");var item=["keypress","click"];
for(var i=0;i<item.length;i++)
{
(function()
{
var items=item[i];
obj["on"+items]=function()
{
alert("thanks for your" + items);
};
})();
}
</script>