<!DOCTYPE html>
<
html
>
<
head
>
<
meta
charset
=
"utf-8"
>
<
meta
name
=
"viewport"
content
=
"width=device-width,initial-scale=1"
>
<
title
>jQuery UI addClass() Example</
title
>
<
link
href
=
rel
=
"stylesheet"
>
<
script
src
=
<
script
src
=
<
style
>
.welcomeClass {
width: 200px;
height: 50px;
text-align:center;
padding :10px 10px 10px 10px;
background-color: lightgreen;
border: 2px solid green;
}
.newClass {
font-size: 40px;
background-color: #cccccc;
color: red;
}
.highlight {
color:#090;
font-family:Calibri;
font-size:2em;
text-shadow:2px 2px #FF0000;
}
.height{ height: 10px;}
.square {
width: 100px;
height: 100px;
text-align: center;
padding :8px 10px 8px 10px;
background-color: #cccccc;
}
.easing-square {
width: 200px;
height: 200px;
padding: 20px;
background-color: lightgreen;
border: 2px solid green;
}
</
style
>
<
script
type
=
"text/javascript"
>
$(document).ready(function() {
$('.btnClass').click(function() {
if (this.id == "addID") {
$('#welcomeId').addClass(
"newClass", "fast")
}
else {
$('#welcomeId').removeClass(
"newClass", "fast")
}
})
$( ".square" ).click(function() {
$( this ).addClass( "easing-square",
700, "swing" );
$( this ).text("addclass() method "
+ "executed successfully!");
});
});
</
script
>
</
head
>
<
body
>
<
h1
style
=
"color:green"
>
GeeksforGeeks
</
h1
>
<
b
class
=
"highlight"
>
jQuery UI addClass method
</
b
>
<
div
class
=
"height"
></
div
><
br
>
<
div
id
=
welcomeId
class
=
"welcomeClass"
>
Welcome !
</
div
>
<
div
class
=
"height"
></
div
><
br
>
<
button
class
=
"btnClass"
id
=
"addID"
>
Add Class
</
button
>
<
button
class
=
"btnClass"
id
=
"removeID"
>
Remove Class
</
button
>
<
div
class
=
"height"
> </
div
><
br
>
<
div
class
=
"square"
>Click this </
div
>
</
body
>
</
html
>