:imageS2C 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 DOM querySelectorAll() method.

The same results can be achieved with valid CSS using $('[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 Examplego to top of page Top

Selects all elements of type image.

In the example below we apply a red border to 'image' elements within the form.


$(function(){
  $('.ourform').submit(function () { return false; }); // disable submit 
  $('#btn2').on('click', function() {
    $('#main form input:image').css('border', '2px solid red');
  });
});

Pie Survey     

Userame:      

Password:               

     

Which pie do you prefer?:

Select a pie shape: 

            


Press the button below to action the above code:


go to home page Homepage go to top of page Top