Скрипт "смена картинок"
Есть скрипт для смены двух картинок при наведении мышки
<script src="scripts/jquery-1.8.2.min.js"></script> <script> $(function() { $('img').hover(function() { var _this = this, images = _this.getAttribute('data').split(','); counter = 0; this.setAttribute('data-src', this.src); // _this.timer = setInterval(function() { if(counter > (images.length-1)) { counter = 0; } _this.src=images[counter]; counter++; }, 500); }, function() { this.src = this.getAttribute('data-src'); clearInterval(this.timer); }); }); </script> <a href="" class="b-socials__link"><img src="images/icon_social-heart_big.png" data="images/icon_social-heart_big.png, images/icon_social-heart_small.png"' alt=""></a> подскажите, как его поправить, чтобы смена картинок происходила не при наведении мышки. а постоянно? |
Уже описывал точь в точь задачу вот тут. Для вашей задачи измените
$(document).ready(function(){ $("#my_a").on('mouseover', function(){ interval = setInterval(changeImg, 1000); }); $("#my_a").on('mouseout', function(){ clearInterval(interval); }); }); на $(document).ready(function(){ interval = setInterval(changeImg, 1000); }); и если нужно останавливать прокрутку, то к нужному событию запилите: clearInterval(interval); |
Часовой пояс GMT +3, время: 23:35. |