How can I make this repeat?

Legend

Jquery:

var picname = ["1.jpg"];
      var pics = 0;

      $("#pic").mouseenter(function() {

        $("#pic").fadeOut(300, function() { 
          $("#pic").attr("src", picname[pics]); 
          pics++;    
          if (pics > 2) {pics = 0;} 
          $("#pic").fadeIn(500); 
        });

      }); 



$("#pic").mouseleave(function() {

        $("#pic").fadeOut(300, function() { 
          $("#pic").attr("src", picname[pics]); 
          pics++;    
          if (pics > 2) {pics = 0;} 
          $("#pic").fadeIn(500); 
        });

  }); 

Html:

 <img id= 'pic' src="1.jpg"/>

I want to repeat itself for exemple when I put my mouse on that picture it changes and when I leave the mouse it become to normal and this repeats itself.

Banana

If you want it to cycle between 2 pictures, you dont need the array with picture names. just do it like this:

$("#pic").mouseenter(function() {
  $("#pic").fadeOut(300, function() {
    $("#pic").attr("src", "http://images.all-free-download.com/images/graphiclarge/banana_clip_art_13734.jpg");
    $("#pic").fadeIn(500);
  });
});
$("#pic").mouseleave(function() {
  $("#pic").fadeOut(300, function() {
    $("#pic").attr("src", "http://images.all-free-download.com/images/graphiclarge/banana_clip_art_13529.jpg");
    $("#pic").fadeIn(500);
  });
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<img id='pic' src="http://images.all-free-download.com/images/graphiclarge/banana_clip_art_13529.jpg" />

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How can I make this repeat?

From Dev

How can I make this repeat forever?

From Dev

How can I make this repeat forever?

From Dev

How can I make random numbers that never repeat in array?

From Dev

How can I repeat matrix?

From Dev

I have to make ng-repeat of a bunch of divs. How can i do that

From Dev

How do I make a countdown repeat?

From Dev

How can I make a directive that encloses the divs used in an ng-repeat?

From Dev

How can I make this traffic light sequence repeat more than once when the button is pressed>

From Dev

How can i make this JS Typing animation repeat in every Three second

From Dev

How can I make this traffic light sequence repeat more than once when the button is pressed>

From Dev

How can I make a swift multiple questions quiz so the questions do not repeat themselves?

From Dev

How can I make Angular/HTML wait 1 second between cycles of ng-repeat?

From Dev

How can i make Bootstrap collapse work properly with nested AngularJS ng-repeat?

From Dev

How can I repeat certain chunks of object with ng-repeat?

From Dev

How can I not repeat the whole part of an OR in an if statement?

From Dev

How can I trigger ng-repeat

From Dev

How can I repeat the last VIM macro?

From Dev

How can I repeat an AnimationSet in java?

From Dev

How can I repeat my texture in DX

From Dev

How can I repeat the last VIM macro?

From Dev

how i can repeat loop for random walk?

From Dev

How can I repeat my entire slideshow?

From Dev

How can I repeat a match in a regular expression?

From Dev

How can I repeat a public class in Java?

From Dev

How can I repeat this animation in CSS?

From Dev

How can I make slope

From Dev

How can I make this recursive?

From Dev

How can I make this sophistictaed?

Related Related

  1. 1

    How can I make this repeat?

  2. 2

    How can I make this repeat forever?

  3. 3

    How can I make this repeat forever?

  4. 4

    How can I make random numbers that never repeat in array?

  5. 5

    How can I repeat matrix?

  6. 6

    I have to make ng-repeat of a bunch of divs. How can i do that

  7. 7

    How do I make a countdown repeat?

  8. 8

    How can I make a directive that encloses the divs used in an ng-repeat?

  9. 9

    How can I make this traffic light sequence repeat more than once when the button is pressed>

  10. 10

    How can i make this JS Typing animation repeat in every Three second

  11. 11

    How can I make this traffic light sequence repeat more than once when the button is pressed>

  12. 12

    How can I make a swift multiple questions quiz so the questions do not repeat themselves?

  13. 13

    How can I make Angular/HTML wait 1 second between cycles of ng-repeat?

  14. 14

    How can i make Bootstrap collapse work properly with nested AngularJS ng-repeat?

  15. 15

    How can I repeat certain chunks of object with ng-repeat?

  16. 16

    How can I not repeat the whole part of an OR in an if statement?

  17. 17

    How can I trigger ng-repeat

  18. 18

    How can I repeat the last VIM macro?

  19. 19

    How can I repeat an AnimationSet in java?

  20. 20

    How can I repeat my texture in DX

  21. 21

    How can I repeat the last VIM macro?

  22. 22

    how i can repeat loop for random walk?

  23. 23

    How can I repeat my entire slideshow?

  24. 24

    How can I repeat a match in a regular expression?

  25. 25

    How can I repeat a public class in Java?

  26. 26

    How can I repeat this animation in CSS?

  27. 27

    How can I make slope

  28. 28

    How can I make this recursive?

  29. 29

    How can I make this sophistictaed?

HotTag

Archive