I have this code, and it works with GetElementsbyId but how can i do such so I can have GetElementsByClassName so I can pass it to more than one place in side the code, here is my code;
Here is the js
var currentTime = new Date()
var month = currentTime.getMonth() + 1
var day = currentTime.getDate()
var year = currentTime.getFullYear()
document.write(month + "/" + day + "/" + year)
document.getElementsByClassName("time").innerHTML=(month + "/" + day + "/" + year);
I would like to be able to use the Current date more than On place in my HtmL page . Thank you
You tagged
jQueryin your question and I’m assume you usejQueryUsing jQuery, you can do,
Demo: http://jsfiddle.net/C6Qgf/3/
Note: If you are using native JavaScript, remember
document.getElementsByClassNamewill not work on IE. There is a workaround to fix, see the below code.Using native JS (with IE support)
Demo: http://jsfiddle.net/C6Qgf/6/