vendredi 15 juillet 2016

setinterval not working to change image src


Wondering why the following code will not change my img src. The commented out example works just fine. And the alert triggers every 4 seconds. Replacing the src just wont work inside the set interval function.

$(document).ready(function(){
    $(".samples_1_1").on("click", function(){
        alert('asdf');
        //$(this).attr("src", "../../static/results/samples_1_2.png");
        setInterval(function() {
          alert('alert 1');
          $(this).src("src", "../../static/results/samples_1_2.png");        
        }, 4000);
      });
    });

Aucun commentaire:

Enregistrer un commentaire