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
- Set the size of background image using CSS ?
- CSS | background-image Property
- How to stretch and scale background image using CSS?
- 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 element id using jQuery ?
- jQuery | change() with Examples
- How to change an HTML element name 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 firstname.lastname@example.org. 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