ctrl+k
Enter a search term above to see results...
Test conditions and check for element existence.
$('selector').is(selector);$('selector').is(fn);Tests if any element matches the selector or passes the function test.
| Name | Type | Description |
|---|---|---|
| selector | string | CSS selector to test |
| fn | function | Test function |
true if at least one element matches, false otherwise.
if ($('p').is('.active')) { console.log('At least one paragraph is active');}$('selector').not(selector);$('selector').not(fn);Removes elements matching the selector or passing the function test.
| Name | Type | Description |
|---|---|---|
| selector | string | CSS selector to exclude |
| fn | function | Test function, return true to exclude |
Query object containing remaining elements.
$('div').not('.ignore').addClass('highlight');$('selector').contains(target);Tests if the first matched element contains the given element.
| Name | Type | Description |
|---|---|---|
| target | string, Element, or Query | Selector, element, or Query to check |
true if contained, false otherwise.
if ($('.container').contains('.highlight')) { console.log('Container has highlighted elements');}const button = document.querySelector('button');if ($('.toolbar').contains(button)) { console.log('Button is inside the toolbar');}const $inputs = $('input[required]');if ($('form').contains($inputs)) { console.log('Form contains required inputs');}$$('web-component').contains('.shadow-element');$('selector').exists();Checks if there are any elements in the Query object.
true if at least one element exists, false otherwise.
if ($('.my-element').exists()) { console.log('Element found');}