← Back to Index

.is()

Check the current matched set of elements against a selector, element, or function.

Examples

1. Check selector

const isChecked = $('input[type="checkbox"]').is(':checked');

Result

true // if at least one checkbox is checked

2. Custom Pseudo-selectors

// <div id="box" style="display:none"></div>
const isVisible = $('#box').is(':visible');

Result

false

3. Check against Function

const hasLongText = $('p').is(function(index) {
     return this.textContent.length > 100;
});

Result

true // if matched logic

Parameters

Parameter Type Description
selector string | function | element | SR A selector expression, a function, a DOM element, or an SR object to match against.

Returns: Boolean.