Codelab Editor
Free Online HTML Editor
Run
Learn jQuery
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0"/> <title>jQuery hasClass() Method</title> <style> body { font-family: Arial, sans-serif; padding: 40px; background-color: #f9f9f9; } h1 { color: #333; } .status-box { padding: 20px; background-color: #fff; border: 1px solid #ccc; border-radius: 6px; margin-top: 20px; box-shadow: 0 2px 5px rgba(0,0,0,0.05); } .active { background-color: #E0F7FA; border: 2px solid #00ACC1; color: #006064; } .message { font-size: 16px; color: #555; margin-top: 10px; } button { margin-top: 15px; padding: 10px 20px; background-color: #00ACC1; color: white; font-size: 14px; border: none; border-radius: 4px; cursor: pointer; } button:hover { background-color: #00838F; } </style> <script src="https://code.jquery.com/jquery-3.7.1.min.js"></script> </head> <body> <h1>jQuery hasClass() Method</h1> <p>The <code>hasClass()</code> method checks whether the selected element has a specified class and returns <code>true</code> or <code>false</code>.</p> <div class="status-box active" id="statusBox">User is Active</div> <button id="checkClassBtn">Check If Active</button> <div class="message" id="resultMsg"></div> <script> $(document).ready(function() { $('#checkClassBtn').click(function() { if ($('#statusBox').hasClass('active')) { $('#resultMsg').text('Yes, the box has the "active" class.'); } else { $('#resultMsg').text('No, the box does not have the "active" class.'); } }); }); </script> </body> </html>
Editor Commands
Ctrl
F
Find
Ctrl
G
Find Next
Ctrl
⇧
G
Find Previous
Ctrl
⇧
F
Find & Replace
Ctrl
]
Indent Code Right
Ctrl
[
Indent Code Left
⇧
Tab
Auto Indent Code
Ctrl
/
Line Comment
Ctrl
Alt
/
Block Comment
TutsInsider Actions
Alt
S
Run Code
Ctrl
C
Copy Editor Code
Ctrl
A
Select All Editor Code
Ctrl
S
Save/Download
Ctrl
Alt
X
Rotate
Ctrl
Alt
T
Switch Theme
Ctrl
⇧
C
Open Console
Esc
Close Console