Articles
Snippets
Categories
Quiz
Encryption
Base64 Encode
Base64 Decode
MD5 Hash
SHA1 Hash
SHA256 Hash
SHA512 Hash
URL Encode
URL Decode
Tools
Password generator
IP Locator
Website Down Detector
Character count
Json Formatter
JavaScript Formatter
HTML Formatter
CSS Formatter
Convert
XML to Json
Json to XML
Works with Us
jquery toggleClass method with example
HTML
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>JQuery toggleClass method</title> <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script> </head> <body> <p class="red">This is text.</p> <button>View</button> <script type="text/javascript"> </script> </body> </html>
CSS
.red { color: red; } .italic { font-style: italic; }
Javascript
$('button').click(function() { $('p').toggleClass('red italic'); });
Run Code
Copyright 2022 HackTheStuff