javascript - How stop slide show on mouse over (slide show should start as usual after mouse out) in java script -


hi, spent more 10 hours stop slide show on mouse on , start on mouse out. saw suggestions in stack overflow didn't solution (may fault understand others code according code. because of giving code).

code is:

<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta content="text/html; charset=iso-8859-1" http-equiv="content-type"/>  <title>simple jquery slideshow jonraasch.com</title>  <script type="text/javascript" src="jquery-1.2.6.min.js"></script>  <script type="text/javascript">  /***      simple jquery slideshow script     released jon raasch (jonraasch.com) under freebsd license: free use or modify, not responsible anything, etc.  please link out me if :) ***/  function slideswitch() {     var $active = $('#slideshow img.active');      if ( $active.length == 0 ) $active = $('#slideshow img:last');      // use pull images in order appear in markup     var $next =  $active.next().length ? $active.next()         : $('#slideshow img:first');      // uncomment 3 lines below pull images in random order      // var $sibs  = $active.siblings();     // var rndnum = math.floor(math.random() * $sibs.length );     // var $next  = $( $sibs[ rndnum ] );       $active.addclass('last-active');      $next.css({opacity: 0.0})         .addclass('active')         .animate({opacity: 1.0}, 1000, function() {             $active.removeclass('active last-active');         }); }  $(function() {     setinterval( "slideswitch()", 1500 ); });  $("#slideshow")(function() { $(this).slides("stop"); }); //playing slides $("#slideshow")(function() { $(this).slides("play"); });  </script>  <style type="text/css">  /*** set width , height match images **/  #slideshow {     position:relative;     height:350px;     width: 40%; }  #slideshow img {     position:absolute;     top:0;     left:0;     z-index:8;     opacity:0.0; }  #slideshow img.active {     z-index:10;     opacity:1.0; }  #slideshow img.last-active {     z-index:9; }  </style>  </head>  <body style="font-family: arial, sans-serif, sans;">   <!-- work number of images --> <!-- set active class on whichever image want show default  (otherwise last image) -->  <div id="slideshow">     <img src="image1.jpg" alt="slideshow image 1" class="active" />     <img src="image2.jpg" alt="slideshow image 2" />     <img src="image3.jpg" alt="slideshow image 3" />     <img src="image4.jpg" alt="slideshow image 4" /> </div>       </body> </html>  

this jsfiddle should example of you're looking for.

there weird parts in code, such $("#slideshow")(function() { $(this).slides("play"); });, don't make sense. removed example.

my example includes hover binding used in johan van den rym's answer.

basically, added boolean keeps track of whether slides being hovered over:

var isstopped = false; function slideswitch() { if (!isstopped) { ...

and @ end added hover states:

$("#slideshow").hover(function () { isstopped = true; }, function () { isstopped = false; });


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -