toggle(fn, fn1): when clicking matched element, the first specified function is fired, clicked again, the second is fired. : toggle « jQuery « JavaScript DHTML





toggle(fn, fn1): when clicking matched element, the first specified function is fired, clicked again, the second is fired.

 



<html>
  <head>
    <script type="text/javascript" src="js/jquery-1.3.2.js"></script>
    <script type="text/javascript">
        $(document).ready(function(){
                
            $("li").toggle(
              function () {
                $(this).css("list-style-type", "disc")
                       .css("color", "blue");
              },
              function () {
                $(this).css({"list-style-type":"", "color":""});
              }
            );



        });
    </script>

  </head>
  <body>
    <body>
         <ul>
            <li>A</li>
            <li>B</li>
            <li>C</li>
            <li>D</li>
         </ul>
       
                         
    </body>
</html>

   
  










Related examples in the same category

1.Click to toggle style
2.Toggle true and false
3.Slow toggle
4.Normal toggle
5.Toggle fast
6.Toggle in milliseconds
7.Toggle among two or more function calls every other click
8.Use toggle function to change class
9.Click to toggle opacity