25

I have this jquery code that changes the image of the background on click:

$('a.note').click(function(){
  $('#full').css('background-image','img/1.jpg');

});

However, it's not changing. Is there something I'm missing?

1

1 Answer 1

46

You need to include the url() part of the background-image property.

$('#full').css('background-image','url(img/1.jpg)');
Sign up to request clarification or add additional context in comments.

5 Comments

how do i remove it the backround image on click function!!! thanks :)) +upvote from me
@getaway: Set it to an empty string. .css('background-image','');
thanks you very much, i will accept the answer when it lets me lol!!
@getaway: Come to think of it, a more appropriate way to remove the image is probably to set it to "none" .css('background-image','none'); since that is the correct value for no background image. css3.com/css-background-image
I would also like to note that there should be NO space between "url" and "(". That was driving me nuts for a couple of hours.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.