How to change the background image using jQuery ? Last Updated : 03 Aug, 2021 Comments Improve Suggest changes Like Article Like Report To change the background image using jQuery, you can use the jQuery CSS() method. For this, the whole property value is specified using the url() functional notation. Approach: Suppose we have an image URL stored in a variable and then use css() method to change the value of background image. Below example illustrates the above approach: Example: html <!DOCTYPE html> <html lang="en"> <head> <title> jQuery Changing background-image CSS Property </title> <style> .box { width: 700px; height: 220px; border: 2px solid black; background-repeat: no-repeat; background-image: url( "https://www.geeksforgeeks.org/wp-content/uploads/javascript-768x256.png"); } h1{ color:green; } </style> <script src="https://code.jquery.com/jquery-1.12.4.min.js"></script> <script> $(document).ready(function() { // Change background image of a div by clicking on the button $("button").click(function() { var imageUrl = "https://www.geeksforgeeks.org/wp-content/uploads/jquery-banner-768x256.png"; $(".box").css("background-image", "url(" + imageUrl + ")"); }); }); </script> </head> <body> <center> <h1>GeeksforGeeks</h1> <h3> jQuery Changing background-image CSS Property </h3> <div class="box"></div> <p> <button type="button"> Change Background Image </button> </p> </center> </body> </html> Output: Before Clicking on the button: After Clicking on the button: jQuery is an open source JavaScript library that simplifies the interactions between an HTML/CSS document, It is widely famous with it's philosophy of “Write less, do more". You can learn jQuery from the ground up by following this jQuery Tutorial and jQuery Examples. Comment More infoAdvertise with us Next Article How to change the background image using jQuery ? M MeghaKakkar Follow Improve Article Tags : Technical Scripter Web Technologies CSS JQuery jQuery-Misc +1 More Similar Reads How to change the position of background image using jQuery ? In this article, we will see how to change the position of the background image using jQuery. To change the position of the background image, we will use css() method with float property. The css() method is used to change the style property of the selected element. The float property is used to cha 2 min read How to Set background Image using jQuery css() Method ? This article will show you how to set the background image using jQuery. To set the background image, we are using the jQuery css() method. jQuery css() MethodThis method sets/returns one or more style properties for the specified elements. Syntax: Return a CSS property:$(selector).css("propertyname 2 min read How to Change Background Images on Scroll using CSS? Background images are crucial in web development, significantly enhancing the user experience. Using background images on a webpage can effectively showcase a brand or convey specific messages. Here, we will explore how to change background images on scroll using CSS. ApproachThe HTML includes a spa 2 min read How to get a div's background image with jQuery ? The task is to get a div's background image with jQuery. You can achieve this task by using the CSS() method in jQuery. In simple words, we need to create an empty div and on click event, the empty div will get the image as a background. CSS(): This is an inbuilt method in jQuery to add the CSS prop 2 min read How to set multiple background images using CSS? The multiple background images for an element can be put in the HTML page using CSS. Use CSS background property to add multiple background images for an element in any pattern and use other CSS property to set the height and width of the images. The used background property are listed below: backgr 2 min read Like