javascript - play/pause gif with mouse event -
I have an image format GIF in my web page.
I want to go with the mouse to play the animation on any image. And as long as the mouse is still there, it stays on the last frame and when the mouse comes back in the original image.
Can anyone help?
Something like this:
HTML
& Lt; Div id = "picture" & gt; & Lt; Div class = "img img1" & gt; & Lt; Img data-gif_src = "http://38.media.tumblr.com/tumblr_mdnaeqwmTr1rtuulro1_250.gif" src = "http://i.dailymail.co.uk/i/pix/2011/12/25/article-2078552 -0F44CB3D00000578-206_468x331.jpg "/> & Lt; / Div & gt; & Lt; / Div & gt; CSS
#images .img {width: 200px; Height: 150px; } #images .img img {width: 200px; Height: auto; } JS
$ ('# images .img img'). Mousecenter (function () {$ (this) .data ('img_src' $ (this) .attr ('src')); $ (this) .attr ('src', $ (this) .data ('gif_src' ));}) MouseLove (function () {$ (this) .attr ('src', $ (this) .data ('img_src'));};
Comments
Post a Comment