Back
Syntax
Study
Editor
Mode:
HTML
CSS
JavaScript
PHP
Reset
Run »
HTML / CSS / JS
// Direct children only var $listItems = $('#nav > ul').children('li'); console.log('Top-level nav items:', $listItems.length); // All descendants $('#data-table').find('td.error').addClass('highlight'); // Scoped find vs global selector var $form = $('#order-form'); var $inputs = $form.find('input, select, textarea'); $inputs.on('change', validateField); // Children with filter $('#gallery').children('img:visible').each(function () { $(this).attr('loading', 'lazy'); }); // .contents() — includes text nodes $('p').contents().filter(function () { return this.nodeType === 3; // text nodes }).wrap('<span class="text-node"></span>');
Result
Open