NextIndexPrevious

Programs in jQuery

18. Removing CSS class to paragraph.

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Untitled Document</title>
<style>
h3{
	width:300px;
	border:1px solid #CCC;
	text-align:center;
	cursor: pointer;
	cursor: hand;
	margin-bottom:20px;
}
.clr{
	background-color:#CCF;
	color:#60F;
}
</style>
<script src="jquery-1.10.2.min.js"></script>
<script>
$(document).ready(function() {
	$("p").addClass("clr");	
    $("h3").click(function(){
		$("p").removeClass("clr");		
	});
});
</script>
</head>

<body>
<h3>Click to remove CSS class</h3>
<p>jQuery is a fast, small and feature-rich <b>JavaScript</b> library.</p>
<p>'Write less: Do more'</p>
</body>
</html>


Output :

Click to remove CSS class

jQuery is a fast, small and feature-rich JavaScript library.

'Write less: Do more'





Creater of JQuery


John Resig

John Resig

Born: May 8, 1984, Boston, U.S.A.