[jQuery] Re: missing background-image

2009-09-13 Thread Scott Haneda


Look at the network panel in firebugs or activity monitor in Safari.  
See what URL is being requested for the images. You can then see where  
there error in your path is.


--
Scott
Iphone says hello.

On Sep 12, 2009, at 11:10 PM, macsig sigbac...@gmail.com wrote:



Hello guys,
I have a series of divs (all with the same CSS class) and I'm trying
to add dynamically a background image to each one (each div needs a
different image) so here my code

$('.panel').css({'background-image' : 'url(../images/sub/'+ $
(this).attr(id) +'.png)'});

but unfortunately my divs don't have any background; however if I
hardcode a image, for instance

$('.panel').css({'background-image' : 'url(../images/sub/bg1.png)'});

every div has the (same) background.

Finally if I print out the image path for each div

$('.panel').each(function(){
alert('url(../images/sub/'+ $(this).attr(id) +'.png)'});
});

the path looks fine.


Am I missing something???

THANKS

Sig


[jQuery] Re: missing background-image

2009-09-13 Thread Macsig

http://localhost:3000/images/sub/undefined.png

but I don't understand why.

Thanks

On Sep 12, 11:19 pm, Scott Haneda talkli...@newgeo.com wrote:
 Look at the network panel in firebugs or activity monitor in Safari.  
 See what URL is being requested for the images. You can then see where  
 there error in your path is.

 --
 Scott
 Iphone says hello.

 On Sep 12, 2009, at 11:10 PM, macsig sigbac...@gmail.com wrote:





  Hello guys,
  I have a series of divs (all with the same CSS class) and I'm trying
  to add dynamically a background image to each one (each div needs a
  different image) so here my code

  $('.panel').css({'background-image' : 'url(../images/sub/'+ $
  (this).attr(id) +'.png)'});

  but unfortunately my divs don't have any background; however if I
  hardcode a image, for instance

  $('.panel').css({'background-image' : 'url(../images/sub/bg1.png)'});

  every div has the (same) background.

  Finally if I print out the image path for each div

  $('.panel').each(function(){
  alert('url(../images/sub/'+ $(this).attr(id) +'.png)'});
  });

  the path looks fine.

  Am I missing something???

  THANKS

  Sig


[jQuery] Re: missing background-image

2009-09-13 Thread Andi23

I think that $(this) may not work in that context.

See if this works:
$('.panel').each(function(){
$(this).css(/*set CSS here*/);
});


[jQuery] Re: missing background-image

2009-09-13 Thread Macsig

You are the man!!!
it works just fine

Thanks and have a good 1

On Sep 13, 9:24 am, Andi23 dowhatyouw...@gmail.com wrote:
 I think that $(this) may not work in that context.

 See if this works:
 $('.panel').each(function(){
     $(this).css(/*set CSS here*/);



 });