Form filters

As if all the previous selectors and filters weren't cool enough, you can also explicitly filter to several types of form elements as well as types of events for those elements. Using these filters, you'll be able to take control of your WordPress generated comment forms as well as custom and WordPress plugin forms and make them even more intuitive and easier to use. Later on in this book, we'll see how jQuery can make form use and validation dead simple.

Example

Syntax

Description

:input

jQuery("form:input").css( "#f60");

"background",

Filters to all input, text area, select, and button elements

:text

jQuery("form:text").css(" "#f60");

background",

Filters to all input elements that are of type text

:password

jQuery("form:password"). css("background", "#f60")

;

Filters to all input elements that are of type passwords

:radio

jQuery("form:radio").css( "#f60");

"background",

Filters to all input elements that are of type radio

:checkbox

jQuery("form:checkbox"). css("background", "#f60")

;

Filters to all input elements that are of type checkbox

:submit

jQuery("form:submit"). css("background", "#f60")

;

Filters to all input elements that are of type submit

:image

jQuery("form:image").css( "#f60");

"background",

Filters to all image elements (classified as a form filter, but useful for regular images)

:reset

jQuery("form:reset").css( "#f60");

"background",

Filters to all input elements that are of type reset

:button

jQuery("form:button")

Filters to all input

.css("background", "#f60"

);

elements that are of type button

file

jQuery("form:file").css(" "#f60");

background",

Filters to all input elements that are of type file

Using the following code, I've highlighted only the text input and submit buttons, as shown in the next screenshot:

jQuery(":text, :submit").css("background", "#f60");

jQuery(":text, :submit").css("background", "#f60");

The Accidental Blogging Millionaires

The Accidental Blogging Millionaires

Get Inspired By The Most Popular Bloggers Online! If You Want To Skyrocket Your Success With Business And Improve Your Overall Life You Need To Have A Look At The Accidental Blogging Millionaires! Business can be a fight, particularly when you’re trying to establish one online and like all fights, to succeed you must find the winning techniques and apply them.

Get My Free Ebook


Post a comment