jQuery addClass method example
Tutorial Javascript jQuery addclass method. Example
by ITpresent
HTML
<div id="content">
<h1>IT present</h1>
<h2>addClass() method</h2>
<h3>Javascript Language</h3>
<button>CLICK HERE</button>
</div>
<br>
<a href="https://itpresent.com/web/jquery/jquery_addclass_onclick_button.php">
Add Clasess to elements by Onclick Button
</a>
CSS
h1 {
font-size: 50px;
}
.a {
background-image: url("https://websitebackgrounds.itpresent.com/graphics/images/class_ch.jpg");
}
.b {
-webkit-text-fill-color:maroon;
-webkit-text-stroke: 1px white;
}
.c {
color:blue;
font-family: Stencil Std, fantasy;
text-shadow: 3px 1px 0px red;
}
.d {
background-color:yellow;
}
JavaScript
$(document).ready(function(){
$("button").click(function(){
$("#content").addClass("a");
$("h1").addClass("b");
$("h2").addClass("c");
$("h3").addClass("d");
});
});