Change BG image

Change BG image

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

  1.    $('html').on('click', function (e) {
  2.      var bgs = ['2.jpg','3.jpg','4.jpg'];
  3.      for(var x in bgs) {
  4.        console.log(bgs[x]);
  5.        $(this).css({
  6.        background : 'url(http://localhost/w-factory/img/'+bgs[x]+')'
  7.       })
  8.      }
  9.    });