This is the rotation script for images

var image = new Array ();
image[0] = "http://placehold.it/20";
image[1] = "http://placehold.it/20";
image[2] = "images/banner3.png";
image[3] = "images/banner4.png";

var size = image.length
var x = Math.floor(size*Math.random())



and this is the output to display

<img id='banner1'/>

Testing it here to see if the script works, and it does http://jsfiddle.net/EpnTH/

but on my website, it's not working.

I am using Simple Custom CSS and JS plugin for the script and img tag placed in the page, the location of my choice, but it's not working.

This code for fixed 1 image is working without issues

<a href="https://wordpress.stackexchange.com">
<img src="images/banner3.png"">

I am here looking for any suggestions that could solve this problem.

  • 1
    Think this is considered off-topic and you should contact the plugin author on their support page. My understanding questions around a plugin are considered out-of-scope. If you want to learn what the site is about then you can take the tour. – DᴀʀᴛʜVᴀᴅᴇʀ Jun 4 '17 at 13:18

Your script doesn't work because you're using $. When WordPress loads jQuery, it does so using no-conflict mode. This disables the $. Replace is with a jQuery instead.

Not the answer you're looking for? Browse other questions tagged or ask your own question.