Ilya Medvedev
Ilya Medvedev

Reputation: 1279

How to change background img with jquery?

How to change background img with jquery by clicking on button?

My code does not work.

$(document).ready(function(){
    $("#go").click(function() {
        $('body').css("background-image", "url(blue_bg.jpg)");  
    };
});

Upvotes: 0

Views: 169

Answers (1)

Ricardo Binns
Ricardo Binns

Reputation: 3246

try fixing like this and see if works:

$(document).ready(function(){
   $("#go").click(function() {
      $('body').css("background-image", "url(blue_bg.jpg)");  
   }); // you forgot to close the click event
});

Upvotes: 8

Related Questions