How can I toggle between 2 images

前端 未结 4 546
醉梦人生
醉梦人生 2020-12-13 16:29

Im trying to use this code to toggle between a play and pause button but it doesn\'t seem to be working. How can I get it toggle between the 2 images when the are clicked

4条回答
  •  甜味超标
    2020-12-13 17:06

    $(document).ready(function(){ var src1 = "http://tympanus.net/PausePlay/images/play.png"; var src2 = "http://maraa.in/wp-content/uploads/2011/09/pause-in-times-of-conflict.png"; $("#infoToggler").click(function(){ var src = $('#infoToggler img').attr('src'); if(src == src1){$('#infoToggler img').attr('src',src2);} else{$('#infoToggler img').attr('src',src1);} });

    })​

    it's working, i had checked..

提交回复
热议问题