Hi Everyone ,
I am trying to build a chrome extension that loads a random image from a folder and on every load of the page , it must show the date in DD-MM-YYYY format. I have got the javascript code for the image to load. However I tried using Moment.js for the Javascript date and it does not seem to work. Can anyone of you guys here help me with it ? Any help is appreciated
Anirudh
Sure here is the JS Code
var totalCount = 30;
function ChangeIt()
{
document.body.style.backgroundRepeat = “no-repeat”;
document.body.style.backgroundSize = “cover”;
var num = Math.ceil( Math.random() * totalCount );
document.body.background = ‘images/’+num+’.jpg’;
}
ChangeIt()
For some reason , the date function is not copying properly in the editor. I am using moment.js
var today = moment().format('LL');
var date = document.getElementById('now').innerHTML = today;
Yeah thanks for the code. I solved the problem. The problem was that I tried to load all the random images as well the date function on 1 js file. I seperated them into js files and it seems to work fine. Thanks a lot anyways