vendredi 6 novembre 2020

JS: Select any avatar from a folder

So I'm working on some project and in some part of the website, I do need to show random avatar images from a specific folder, each X seconds (I'm using setInterval for this).

BUT the problem is that I can't select random images.

So basically this is a part of my code:

setInterval(function() {
    $('#avatar').attr('src', 'assets/img/avatars/*.jpg');
}, 1500);

As you can see, I've tried that *.jpg but it doesn't work.

Do you have any other ideas?

Thank you!




Aucun commentaire:

Enregistrer un commentaire