The getElementsByClassName()
function (note the s in "Elements") returns a NodeList, not a single node. You have to iterate through the list to operate on each node individually.
You can do it with a simple for
loop:
var selects = document.getElementsByClassName("p1");
for (var i = 0; i < selects.length; ++i)
selects[i].innerHTML = Date;
I suspect strongly that your code has another problem: you're creating a global variable called "Date", and that will clobber the JavaScript "Date" constructor binding. Use another name (like lower-case "date").