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 siblings() – Get All Sibling Elements</title> <script src="https://code.jquery.com/jquery-3.7.1.min.js"></script> <style> body { font-family: Arial, sans-serif; background: #f9f9f9; padding: 30px; } h2 { color: #333; } .description { margin-bottom: 20px; color: #666; } .parent-box { border: 2px solid #999; padding: 15px; background: #fff; width: 400px; } .item { margin: 5px 0; padding: 10px; background: #e8f6f3; border: 1px solid #76d7c4; cursor: pointer; } .highlight { background: #ffebcc; border-color: #f5b041; } </style> </head> <body> <h2>jQuery siblings() – Get All Sibling Elements</h2> <p class="description"> Click any item to highlight all of its <strong>siblings</strong> using the <kbd>siblings()</kbd> method. </p> <div class="parent-box"> <div class="item">Item A</div> <div class="item">Item B</div> <div class="item">Item C</div> <div class="item">Item D</div> </div> <script> $(function () { $('.item').on('click', function () { $('.item').removeClass('highlight'); // Reset all $(this).siblings().addClass('highlight'); // Highlight siblings }); }); </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