javascript - Jquery image slider with mouse over event -
In
, the first image is automatically slide, but every image that I put the mouse over them should slide.
I have Onmouseover
event in html and given a name to the main function like below but it does not work.
How can I do jQuery Image Slider with a mouse?
HTML:
& lt; Ul onmouseover = "imageSlider ()" id = "example sliders" & gt; & Lt; Li & gt; & Lt; IMG src = "http://placehold.it/500x250" alt = "" / & gt; & Lt; / Li & gt; & Lt; Li & gt; & Lt; Img src = "http://placehold.it/500x260" alt = "" /> & lt; / Li & gt; & Lt; Li & gt; & Lt; IMG src = "http://placehold.it/500x270" alt = "" / & gt; & Lt; / Li & gt; & Lt; Li & gt; & Lt; IMG src = "http://placehold.it/500x280" alt = "" /> gt; & Lt; / Li & gt; & Lt; / Ul & gt; & Lt; Ul onmouseover = "imageSlider ()" id = "example sliders" & gt; & Lt; Li & gt; & Lt; IMG src = "http://placehold.it/500x250" alt = "" / & gt; & Lt; / Li & gt; & Lt; Li & gt; & Lt; Img src = "http://placehold.it/500x260" alt = "" /> & lt; / Li & gt; & Lt; Li & gt; & Lt; IMG src = "http://placehold.it/500x270" alt = "" / & gt; & Lt; / Li & gt; & Lt; Li & gt; & Lt; IMG src = "http://placehold.it/500x280" alt = "" /> gt; & Lt; / Li & gt; & Lt; / Ul & gt; Javascript: function imageSlider () {/ * SET parameter / var change_img_time = 3000; Var transition_speed = 300; Var simple_slideshow = $ ("# exampleSlider"), listItems = simple_slideshow.children ('li'), listLen = listItems.length, i = 0, changeList = function () {listItems.eq (i). FadeOut (transition_speed, function () {I + = 1; if (i === list lane) {i = 0;} listItems.eq (i) .fadeIn (transition_speed);}); }; . Hide listItems.not (': first') (); SetInterval (changeList, change_img_time); };
I'm not sure that you are trying it! Try
$ ('img'). Use mouseenter (function () {// or you can use the hover () // Set the effect type var effect = 'slide'; // Options for the options set effect var option = {direction: "right "}; // Set the duration (default: 400 milliseconds) var period = 1000; $ (this). Toggle (effect, option, duration);});
Bela
Comments
Post a Comment