91 of 119 menu

image selector

The selector :image selects elements of type image, which are images for form submission. The equivalent of $(':image') is $('[type=image]'). Since :image is not part of the CSS specification, for better performance in modern browsers it is better to use [type='image'] instead.

Syntax

This is how we select elements with type image:

$(':image');

Example

Let's select all inputs with type image and give them a green background and a red border using the css method:

<form> <input type="button" value="button"> <input type="file"> <input type="password"> <button>button</button> <input type="reset"> <input type="radio" name="test"> <input type="radio" name="test"> <input type="checkbox"> <input type="image"> <input type="text"> </form> $('input:image').css({background: 'green', border: '2px red solid'}); $('form').submit(function(event) { event.preventDefault(); // prevents form submission });

See also

  • method filter,
    which filters elements in a set by a given selector
  • method css,
    which allows you to get and change the CSS styles of an element
  • selector submit,
    which selects elements with type submit that are form submit buttons
English
AfrikaansAzərbaycanБългарскиবাংলাБеларускаяČeštinaDanskDeutschΕλληνικάEspañolEestiSuomiFrançaisहिन्दीMagyarՀայերենIndonesiaItaliano日本語ქართულიҚазақ한국어КыргызчаLietuviųLatviešuМакедонскиMelayuမြန်မာNederlandsNorskPolskiPortuguêsRomânăРусскийසිංහලSlovenčinaSlovenščinaShqipСрпскиSrpskiSvenskaKiswahiliТоҷикӣไทยTürkmenTürkçeЎзбекOʻzbekTiếng Việt
We use cookies for website operation, analytics, and personalization. Data processing is carried out in accordance with the Privacy Policy.
accept all customize decline