Possible Duplicate:
When to use setAttribute vs .attribute= in JavaScript?
Why do you sometimes set an attribute like this:
x.type = "submit";
and other times like this:
x.setAttribute("type", "submit");
I always figured it didn't matter which way, but I'm having an issue doing this:
x.onClick = save;
but when I switch it to this it works:
x.setAttribute("onClick", "save()");
x.onClick = savedoes not work because JavaScript is case-sensitive. The property isonclick:x.onclick = save;. HTML is not case-sensitive, so<... onclick="save()">,<... onClick="save()">and<... ONCLICK="save()">are all the same.