jQuery toggle() toggle a list of functions

Description

jQuery toggle() toggle a list of functions

View in separate window

<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8/jquery.min.js">
</script>//from ww  w . j  a va2s .c o  m
<script>
$(document).ready(function(){
  $("li").toggle(
    function(){$(this).css({"color": "red"});},
    function(){$(this).css({"color": "blue"});},
    function(){$(this).css({"color": "purple"});},
    function(){$(this).css({"color": "yellow"});
  });
});
</script>
</head>
<body>

<p>Click several times on each of the list items below:</p>

<ul>
  <li>CSS</li>
  <li>HTML</li>
</ul>
</body>
</html>



PreviousNext

Related