Flag Example in jQuery

  1. <html >  
  2. <head>  
  3. <title></title>  
  4. <script src="Scripts/jquery-2.1.1.js" type="text/javascript"></script>  
  5. <script type="text/javascript">  
  6. $(document).ready(function(){  
  7. $("#divTitle").addClass("style1");  
  8. var flag=true;  
  9. function blinkstyle(){  
  10. if(flag==true)  
  11. {  
  12. if($("#divTitle").hasClass("style1"))  
  13. $("#divTitle").removeClass("style1");  
  14. $("#divTitle").addClass("style2");  
  15. flag = false;  
  16. }  
  17. else {  
  18. if ($("#divTitle").hasClass("style2"))  
  19. $("#divTitle").removeClass("style2");  
  20. $("#divTitle").addClass("style1");  
  21. flag = true;  
  22. }  
  23. }  
  24. window.setInterval(blinkstyle,200);  
  25. });  
  26. </script>  
  27. <style type="text/css">  
  28. .style1 {  
  29. text-align:center;  
  30. width:70%;  
  31. height:100px;  
  32. line-height:100px;  
  33. background-color:red;  
  34. color:white;  
  35. font-family:Tahoma;  
  36. font-size:60px;  
  37. border:5px solid green;  
  38. border-radius:10px;  
  39. box-shadow:gray 10px 15px;  
  40. }  
  41. .style2 {  
  42. text-align:center;  
  43. width:70%;  
  44. height:110px;  
  45. line-height:95px;  
  46. background-color:yellow;  
  47. color:red;  
  48. font-family:'Monotype Corsiva';  
  49. font-size:100px;  
  50. border:7px solid green;  
  51. border-radius:20px;  
  52. box-shadow:green 10px 15px;  
  53. }  
  54. </style>  
  55. </head>  
  56. <body>  
  57. <form id="form1" runat="server">  
  58. <div id="divTitle">  
  59. <b>Mithilesh kumar singh</b>  
  60. </div>  
  61. </form>  
  62. </body>  
  63. </html>