Mensur Mensur - 2 months ago 5
Javascript Question

Add background image property to Jquery

I would like to know how to add css background-image:url("xxxxx") property to my code.

jQuery('#'+$trackID+' .sc_thumb').attr('src',$thumb_url);
jQuery('#'+$trackID+' .sc_container').css('display','block');

What i would like to do is to add to the second row property background-image:url("") and put the $thumb_url value inside so I can have a background from that image.

I guess this should be added to .css property somehow, and I have tried different ways but I can't get this to work. Any ideas?


you can try

jQuery('#'+$trackID+' .sc_container')
    'background-image' : 'url('+ $thumb_url +')'


jQuery('#'+$trackID+' .sc_container')
.css('background-image' , 'url('+ $thumb_url +')');