How to verify background (css) image was loaded?

前端 未结 5 1382
离开以前
离开以前 2021-02-03 22:00

I have the following CSS class that I\'m applying on a tag:

.bg {
   background-image: url(\'bg.jp         


        
5条回答
  •  隐瞒了意图╮
    2021-02-03 22:35

    @Jamie Dixon - he didn't say he wanted to do anything with the background image, just know when it's loaded...

    $(function( )
    {
        var a = new Image;
        a.onload = function( ){ /* do whatever */ };
        a.src = $( 'body' ).css( 'background-image' );
    });
    

提交回复
热议问题