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:
- JQuery | Setting background-image using CSS property
- HTML | Change Background color using onmouseover property
- CSS | background-image Property
- Set the size of background image using CSS ?
- How to stretch and scale background image using CSS?
- CSS | Combine background image with gradient overlay
- How to give text or an image transparent background using CSS?
- Background Subtraction in an Image using Concept of Running Average
- How to change color of PNG image using CSS?
- How to change an input button image using CSS?
- CSS | Animation to Change the Hover State of a Button/Image
- How to change the checkbox value using jQuery ?
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Improved By : nidhi_biet