jQuery addClass example
Change class name on click in jQuery
by felipero7
HTML
<!DOCTYPE html>
<html>
<head>
<style>
</style>
</head>
<body>
<p>The first paragraph 1.</p>
<p>The second paragraph.</p>
<p>The third paragraph.</p>
<p>The fourth paragraph.</p>
<p>The first paragraph.</p>
<p>The second paragraph.</p>
<p>The third paragraph.</p>
<p>The fourth paragraph.</p>
<p>The first paragraph.</p>
<p>The second paragraph.</p>
<p>The third paragraph.</p>
<p>The fourth paragraph.</p>
</body>
</html>
JavaScript
$( "p" ).first().css('color', '#0000FF');
$( "p:nth-child(4n+1)" ).css('color', '#00FF00');
$( "p:nth-child(4n+2)" ).css('color', '#0000FF');