Hi everyone! I hope someone can help me!
I want change html background img on click
So, i create an array with images and a for to iterate in array.
But, on click, don´t change imgs bg as i want.
Follow the code below
- $('html').on('click', function (e) {
- var bgs = ['2.jpg','3.jpg','4.jpg'];
- for(var x in bgs) {
- console.log(bgs[x]);
- $(this).css({
- background : 'url(http://localhost/w-factory/img/'+bgs[x]+')'
- })
- }
- });
-