Toggling an image src with jQuery

后端 未结 7 604
孤街浪徒
孤街浪徒 2020-12-06 03:30

I wrote some code to toggle the src of an image and also to pause/resume the jQuery cycle2 plugin.

I\'m not sure why it isn\'t working and would appreciate some help

7条回答
  •  不思量自难忘°
    2020-12-06 04:17

    I know this is a late answer but what about using something simplier like:

    $('.play-pause').click(function () {
        var _this = $(this);
        if (_this.attr("src") == '/images/template/pause.png') {
            _this.attr('src', '/images/template/play.png');
            $('.cycle-slideshow').cycle('pause');
        } else {
            _this.attr('src', '/images/template/pause.png');
            $('.cycle-slideshow').cycle('resume');
        }
    });
    

提交回复
热议问题