Show the random Ad banners easily with JQuery

For display random Ad banners when user refresh browser, we can use a bit of code bellow:

Copy and paste this code into your Javascript file:




In this code, we use banners arrays to save all of banner that we want to show with index is a random position in this array.
We use Math.random to get number of index with max is banners.length

Don't for get add Jquery file from CDN on header tag like this:




Add an element that you want to show the banner, put the default banner inside it:




© 2019 4codev

Created with love by Sil.