Search code examples
javascriptjquerycssbackground-image

How to use Stacking Order of Multiple Backgrounds with jQuery .css()


How can I target multiple background property with css() in jQuery

Example:

    body {    
       background: 
          url("img1.png"),
          url("img2.png"),
          url("img3.png");
    }

Solution

  • You would use the css method like you would any other style attribute.

    $('body').css('background-image', 
       'url("https://www.w3schools.com/css/img_flwr.gif"),'
       + 'url("https://www.w3schools.com/css/paper.gif")'
    );