Prev Demo
jQuery
>
.Toggleclass() - Toggle Class Attribute
Next Demo
Write code here
J
|
B
|
A
<!DOCTYPE html> <html> <head> <title>Demo</title> <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script> <style> .class1 { background-color:green; color:yellow; } </style> </head> <body> <p>TechFunda.com code editor</p> <input type="button" id="btnToggleClass" value="Toggle Class" /> <div id="div2" class="class1">This is Div 52</div> <script> $("#btnToggleClass").click(function () { $("#div2").toggleClass("class1"); }); </script> </body> </html>
Note: We DO NOT save your trial code in our database.
Output