-1

I am new to Jquery and trying out something to learn. I am using the below code to set the backgroundImage in the HTML but it is not working ( no background image is being shown )

$(this).css({"background-image" : "url(file:///users/i304223/Pictures/02872_takeflight_2880x1800.jpg)"});

My Question :

  1. Is body selector correct? Or should I use 'this' instead of body?
  2. Where should I place my jpg file in my project?
  3. What is the correct API to use to show the background image.
  4. Also if anyone can direct me to great Sample UI developed using Jquery,

it would be really nice as it would help me learn by trying different things.

udondan
  • 57,263
  • 20
  • 190
  • 175
Ankur
  • 417
  • 1
  • 4
  • 22

1 Answers1

0
  1. You haven't targeted a proper selector. Please avoid using $(this) while you are new to jQuery which carry different meaning in different places. It's little confusing to newbies. Read more in MDN For now just simply target $('body').

  2. Create a new directory named ie: images (or whatever you want) on the project root and place all your images in there. Read more

  3. Your syntax was correct. Please try loading some content inside the html element or give a min-height of it.

  4. I'd refer you to read Codrops.com, Codepen.io if you want to explore and learn.

Anwar Hussain
  • 450
  • 2
  • 12