jQuery toggle class

A simple example of a using the jQuery toggleClass() function.
<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0">
    <meta name="description" content="jQuery example for Tizen"/>
    
    <title>jQuery example for Tizen</title>
    
<style>
	.red {
	    position:absolute;
		background:#DD0000;
		height:120px;
		width:150px;	
	}
</style>

  <script src="js/jquery-2.1.4.min.js"></script>

</head>
<body>

  <button>Click me to toggle the class!</button>
  <div id="sampleDiv">This DIV is red</div>

<script> 
	$("button").click(function(){
	    $("#sampleDiv").toggleClass("red");
	});
</script>

</body>
</html>

Responses

0 Replies