Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 4th, 2012  |  syntax: None  |  size: 0.93 KB  |  hits: 8  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. jQuery: $(document).ready(function() {function1(1)}); - how to stop performing function1 when variable exceed some value?
  2. $(document).ready(function() {
  3. function1(1);
  4. //some more functions
  5. });
  6.  
  7.  
  8. function function1(hide){
  9. if((hide<10)){
  10.     if (hide%2==1){
  11.         $('.myclass2').css("color","black");
  12.     }
  13.     else{
  14.         $('.myclass2').css("color","white");
  15.     }
  16.     hide = hide+1;
  17.  
  18. }
  19. else{
  20.   //some code to stop performing of this function.
  21. }
  22. setTimeout("blinks("+hide+")",300);
  23. }.
  24.        
  25. $(document).ready(function() {
  26.     var blink =  setInterval("function1(1)",300);
  27.     //some more functions
  28. });
  29.        
  30. clearInterval(blink);
  31.        
  32. function function1(hide){
  33. if((hide<10)){
  34.     if (hide%2==1){
  35.         $('.myclass2').css("color","black");
  36.     }
  37.     else{
  38.         $('.myclass2').css("color","white");
  39.     }
  40.     hide = hide+1;
  41.  
  42.     setTimeout("blinks("+hide+")",300); // moved here
  43. }
  44. else{
  45.   //some code to stop performing of this function.
  46. }
  47. }.