I want to add a background image from JQuery.
I tried like everything but my the background-image won’t show.
My code (example):
$(function() {
var cssObj =
{
'background-image' : 'url(http://blog.stackoverflow.com/wp-content/uploads/stackoverflow-logo-300.png)'
}
$('.Main').css(cssObj);
});
<div class="Main"></div>
JSfiddle: http://jsfiddle.net/334N7/5/
I have tried your code and it works. The problem is that your div is empty and has no height.
Check out my sample and this jsFiddle
Update
Your jsFiddle does not work because your forgot to set
jQueryas the frameworkHere is your updated jsFiddle
Update
I have checked your site. The reason why it does not works is that the image
arrowright.pngis not there or at another path. It results in aChange
to