Changing background when jQuery is stuck or when the img src attribute cannot be updated

I spent several hours trying to figure it out.

I have a store display that goes through properties, and I embossed a simple gallery view of the script. Last week, he worked beautifully.

Today I came to redo some kind of unrelated JavaScript (but on the same page), and now there is a problem.

To change the images to each other, I update img srcand then reduce it to the next image of the element imgcontaining the background of the element.

Now it looks like sometimes the background #main-imagegets stuck on the previous image, despite the fact that I set it using the jQuery method css().

It is available for viewing here.

http://vanquish.websitewelcome.com/~utopia66/store-display

I must emphasize that this is happening in Google Chrome, and I only target this browser.

For your convenience, I have also accelerated the speed of cycling images to save you time.

So why is the image stuck and how can I fix it? update on closer inspection, it may turn out that the element is imgstuck, i.e. it cannot update the attribute src. update again . I am sure this is the background.

Javascript here

http://vanquish.websitewelcome.com/~utopia66/assets/js/display.js

I really appreciate any help!

Thanks a lot.

+3
source share
2 answers

, , backgroundImage .

$('#something').css({ backgroundImage: 'url("' + pathToImage + '")' });

.

!

, - :)

0

, /, - , . , :

$('#something').attr('src', 'pathToImage').load(function(){$(#something).fadeOut('slow')});
0

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


All Articles