Possible duplicate:
When to use setAttribute vs .attribute = in JavaScript?
Why do you sometimes set this attribute:
x.type = "submit";
and at other points:
x.setAttribute("type", "submit");
I always thought that no matter which direction, but I have a problem:
x.onClick = save;
but when I switch it to this, it works:
x.setAttribute("onClick", "save()");
source
share