:input
S2C Home « Selectors « :input
Form input selector.
Shorthand version $(':input')
Description
The :input
selector, selects all button, input, select and textarea elements.
- Being a jQuery extension the
:input
pseudo selector is not part of any current CSS specification. Therefore:input
cannot take advantage of the performance boost provided by the native DOMquerySelectorAll()
method. - Best results can be achieved by using the
:input
selector in conjunction with.filter()
via$("cssSelector").filter(":input")
- If this selector is not preceded by another selector, the universal selector ("*") is implied and so the whole DOM will be searched. Use another selector as in the example below to narrow the search and improve performance.
Syntax
Signature | Description |
---|---|
jQuery(':input') | Form input pseudo-class match |
Parameters
None.
Return
N/A.
:input
ExampleTop
Selects all button, input, select and textarea elements.
In the example below we apply a red border to 'input' elements within the form.
$(function(){
$('.ourform').submit(function () { return false; }); // disable submit
$('#btn1').on('click', function() {
$('.ourform :input').css('border', '1px solid red');
});
});