Click here to Skip to main content
15,918,178 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
See more:
HTML
<html>
<head>
<script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.10.2.min.js">
</script>
<script>
var test = function(){
    if(keepGoing){
        var pre = $("ul li:first-child"); 
        pre.each(function(i){ 
            $(this).slideUp(function(){
                $(this).appendTo(this.parentNode).slideDown();
            });
        });
    }
}

var keepGoing = true;

window.setInterval(test, 3000);

$("ul").hover(function(){
    keepGoing = false;
}, function(){
    keepGoing = true;
});
</script>

</head>
<body><ul> 
      <li>list 1</li> 
      <li>list 2</li>
      <li>list 3</li>
      <li>list 4</li>
   </ul></body></html>

I just want to stop list to rotate when hovered . Can anybody tell me where i am going wrong .
Posted
Updated 27-Sep-13 22:50pm
v2

HTML
<html><head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title> finally i did it</title>
  
  <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js"></script>
  
  
  
  <link rel="stylesheet" type="text/css" href="/css/result-light.css">
  
  <style type="text/css">
    
  </style>
  


<script type="text/javascript">//<![CDATA[ 
$(window).load(function(){
var test = function(){
    if(keepGoing){
        var pre = $("ul li:first-child"); 
        pre.each(function(i){ 
            $(this).slideUp(function(){
                $(this).appendTo(this.parentNode).slideDown();
            });
        });
    }
}
 
var keepGoing = true;
 
window.setInterval(test, 3000);
 
$("ul").hover(function () {
          keepGoing = false;
          test();
      }, function () {
          keepGoing = true;
          test();
      });
});//]]>  

</script>


</head>
<body style="">
  <ul> 
       
      
      
      
   <li style="display: list-item;">list 2</li><li style="display: list-item;">list 3</li><li style="display: list-item;">list 4</li><li style="display: list-item;">list 1</li></ul>
  





</body></html></link></html>
 
Share this answer
 
Your code is working.I have put it on below mentioned link.Check that.

http://jsfiddle.net/dLLrt/[^]


UPDATE

You may try something is as below.

C#
$("ul").mouseover(function() {
   keepGoing = false;
  }).mouseout(function() {
    keepGoing = true;
  });


UPDATE 2

Try my final Update:

C#
$("ul").hover(function () {
          keepGoing = false;
          test();
      }, function () {
          keepGoing = true;
          test();
      });
 
Share this answer
 
v3
Comments
praveen iThesisArt 28-Sep-13 5:01am    
Yep its working fine over there but when am making this html file in c drive and running it , list isn't stopping at all.
Sampath Lokuge 28-Sep-13 5:14am    
You won't host your app on c drive know?So Then just host that on IIS and test it.B'cos your getting jQuery through CDN it might not work,Due to internet issue or something else.If you need to test on locally, add jQuery library into your local folder and set that path to above code snippet and try to test.
praveen iThesisArt 28-Sep-13 5:21am    
I know that. If internet would have been causing any issue the list should also be not rotating . Anyway you can check - http://contact.buildvocab.com/ here i got it uploaded and its not stopping. :(.
Sampath Lokuge 28-Sep-13 5:57am    
Plz,Check my UPDATE section and try that.
praveen iThesisArt 28-Sep-13 9:42am    
Sorry, Sir but this code isn't working .I again uploaded amended code over - http://contact.buildvocab.com/ .

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900