Switch to jQuery background image

I have a div that has the image "home.jpg" as the background, and I want the background to be "another_image.jpg" when I click on something. The fact is that I want the new background to disappear, and not just appear (by doing some .css ('background', url ('another_image.jpg'));)

Is there any way to do this? I tried the bgImageTransition plugin, but it just adds another element on top of the div that I had ...

Thank,

+3
source share
3 answers

The only way to do this is to fade in another element with a new background.

, .

+3

... . , , script.

.

+1

EDIT: added crossfade effect: http://jsfiddle.net/8vHa2/3/

(Click the jQuery logo)

Keep in mind that this kind of effect requires the second element to disappear or be enabled, so I recommend that you stick with the plugin that you tried to execute.

0
source

Source: https://habr.com/ru/post/1746766/


All Articles