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 addClass() to Multiple Elements</title> <style> body { font-family: Arial, sans-serif; padding: 40px; background-color: #f5f5f5; } h1 { color: #333; } .box1, .box2, .box3{ width: 100px; height: 100px; background-color: #ccc; margin: 10px; display: inline-block; border-radius: 4px; transition: all 0.3s ease; } .highlight { background-color: #FF9800; box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2); transform: scale(1.1); } button { margin-top: 20px; padding: 10px 20px; background-color: #FF9800; color: #fff; border: none; border-radius: 4px; cursor: pointer; } button:hover { background-color: #FB8C00; } </style> <script src="https://code.jquery.com/jquery-3.7.1.min.js"></script> </head> <body> <h1>Apply Class to Multiple Elements</h1> <div class="box1"></div> <div class="box2"></div> <div class="box3"></div> <br/> <button id="highlightAll">Highlight All Boxes</button> <script> $(document).ready(function(){ $('#highlightAll').click(function(){ $('.box1, .box2, .box3').addClass('highlight'); }); }); </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