开发者

How to change background-image css property w/jquery

开发者 https://www.devze.com 2023-01-03 22:43 出处:网络
How can I set the background-image css property of say a div using jquery? 开发者_运维技巧will something like this work?

How can I set the background-image css property of say a div using jquery? 开发者_运维技巧will something like this work?

$("#div").css("backgroundImage", "url('test.jpg')");


What you have will work, or you can do this:

$("#div").css("background-image", "url('test.jpg')");

Or .css() takes an object (to set many properties for example):

$("#div").css({ backgroundImage: "url('test.jpg')", color: "red" });
0

精彩评论

暂无评论...
验证码 换一张
取 消