where do you put the image file (image.png)? If it is in the same directory as in the .html file, you could try this
$('#id').css('background-image','url("image.png")');
質問
I don't know why does this code not work on chrome and safari, but in mozilla works fine?
$('#id').css('background-image','url(/image.png)');
I also tried this
$('#id').css('background-image','url("/image.png")');
$('#id').css('backgroundImage','url("/image.png")');
$('#id').css('backgroundImage','url(/image.png)');
but still doesn't work.
正しい解決策はありません
他のヒント
where do you put the image file (image.png)? If it is in the same directory as in the .html file, you could try this
$('#id').css('background-image','url("image.png")');
$('selector').css('backgroundImage','url(images/myImage.jpg)');
$('selector').css({'background-image':'url(images/myImage.jpg)'});
The latter example allows for multiple rules. Check out the API for more details.
Edit: Make sure your path(s) to your image(s) are correct by inspecting the console. That should tell you if you are getting a 404.