开发者

Make the background through javascript

开发者 https://www.devze.com 2023-02-03 21:20 出处:网络
I want to put the background after you downlo开发者_开发百科ad the entire code and files in html. It can however be done. Make it so that the background is loaded after all the content.Set it after th

I want to put the background after you downlo开发者_开发百科ad the entire code and files in html. It can however be done. Make it so that the background is loaded after all the content.


Set it after the DOM loads:

$(function() {
    $("body").css("background-color", "red");
});

or after the whole page (e.g. images) has loaded:

$(window).load(function() {
    $("body").css("background-color", "red");
});  


If by background you mean a background image:

$(function(){
    $('body').css('background','url(\'url-to-background-image\')');
});
0

精彩评论

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