Return to Snippet

Revision: 56620
at April 5, 2012 09:42 by burnandbass


Initial Code
<!DOCTYPE html>
<html>
  <head>
    <title>JS literations</title>
    <meta charset="UTF-8">

	<script language="Javascript" type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
	  	
	<script type="text/javascript">
	  	
		$(function(){
		
			var volumes = ["10", "20", "30", "40", "50", "55", "60", "80", "100"];
			var currentVolume = -1;
		
			$("#buttonClick").click(function(){
				currentVolume = ( ++currentVolume % volumes.length );
				$("#log").html("volume: " + volumes[currentVolume] + " %");
				return false;
			});
			$("#buttonClick").click();
		});
		
	</script>

  </head>
  <body>
	<a href="#" id="buttonClick">change volume<a>
	<p id="log">volume</p>
</body>
</html>

Initial URL


Initial Description
This is perfect for "cycling" items...

Initial Title
Iterate trough array - 1,2,3,1,2,3...etc

Initial Tags


Initial Language
jQuery