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 Traversing Filtering - even() Method</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; margin-bottom: 10px; } .description { margin-bottom: 20px; color: #666; } .btn { display: inline-block; padding: 10px 20px; margin-bottom: 20px; font-size: 16px; font-weight: 600; color: #fff; background-color: #8e44ad; border: 2px solid #71368a; border-radius: 4px; cursor: pointer; text-decoration: none; transition: background-color 0.2s, border-color 0.2s; } .btn:hover { background-color: #1a252f; border-color: #0e141a; } .item-list { border: 2px solid #999; padding: 15px; background: #fff; width: 400px; } .item { margin: 5px 0; padding: 10px; background: #e8f6f3; border: 1px solid #76d7c4; } .highlight { background: #ffebcc; border-color: #f5b041; } </style> </head> <body> <h2>jQuery Traversing Filtering - even() Method</h2> <p class="description"> Click the button below to highlight all <strong>even-indexed</strong> items (0, 2, 4...) using the <kbd>even()</kbd> method. </p> <button id="highlight-even" class="btn">Highlight Even Items</button> <div class="item-list"> <div class="item">Item 1</div> <div class="item">Item 2</div> <div class="item">Item 3</div> <div class="item">Item 4</div> <div class="item">Item 5</div> <div class="item">Item 6</div> </div> <script> $(function () { $('#highlight-even').on('click', function () { $('.item').removeClass('highlight'); // reset $('.item').even().addClass('highlight'); // apply to even indexes (0-based) }); }); </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