Changing background image using jquery

北城以北 提交于 2019-11-26 23:19:03

问题


I have this jquery code that changes the image of the background on click:

$('a.note').click(function(){
  $('#full').css('background-image','img/1.jpg');

});

However, it's not changing. Is there something I'm missing?


回答1:


You need to include the url() part of the background-image property.

$('#full').css('background-image','url(img/1.jpg)');


来源:https://stackoverflow.com/questions/4578714/changing-background-image-using-jquery

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!