:image
JQ Home <<
Selectors <<
:image
Form image selector.
Shorthand version $(':image')
Description
The :image
selector, selects all elements of type image.
- Being a jQuery extension the
:image
pseudo selector is not part of any current CSS specification. Therefore:image
cannot take advantage of the performance boost provided by the native DOMquerySelectorAll()
method. - The same results can be achieved using the Attribute Equals Selector via
$('[type=image]')
, without the hit to performance. - 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(':image') | Form image pseudo-class match |
Parameters
None.
Return
N/A.
:image
Example
Selectors << Top
Selects all elements of type image.
In the example below we apply a red border to 'image' elements within the form when the button is clicked.
$(function(){
$('.ourform').submit(function () { return false; }); // disable submit
$('#btn1').on('click', function() {
$('form input:image').css('border', '2px solid red');
});
});
Related Tutorials
jQuery Basic Tutorials - Lesson 4 - jQuery Selectors