Home  >  Article  >  Web Front-end  >  jquery form filter

jquery form filter

无忌哥哥
无忌哥哥Original
2018-06-29 11:29:361331browse

Form filter

1 Select form control elements according to type

css writing method, only all inputs are selected, other controls cannot be selected

$('input').css('background-color', 'lightgreen')

jquery To write, just add a colon in front of it. Except for input, select, button, and textarea, you can select

$(':input').css('background-color', 'lightgreen')

. If you only want to select the input tag, add the tag limit: input before: input. At this time It is completely consistent with the effect of css syntax

$('input:input').css('background-color', 'lightgreen')

: input: The original intention is to select all form controls. You can use css attributes to restrict it later, such as getting the password box

$(':input[type="password"]').css('background-color', 'lightgreen')

In addition to using css later In addition to attribute restrictions, it is more recommended to use jquery filters. For example, the password box filter is: password

$(':input:password').css('background-color', 'lightgreen')

Change the color to show the difference. As can be seen from here, chain operations are also supported between filters

$(':input:password').css('background-color', 'skyblue')

Let’s do a few more exercises

2. Select elements based on the characteristics of the form control

:input, only select form elements, excluding:file,:image, :input We have already done this

Select only the file type

$(':file').css('background-color', 'lightgreen')

Select only the text box:type="text"

$(':text').css('color',"red")

Select only the submit button

$('button:submit').css({
'background-color':'orange',
'color':'white',
'font-size':'1.2em',
'border': 'none',
'width':'90px',
'height':'40px'
})

The above is the detailed content of jquery form filter. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:jquery content filteringNext article:jquery content filtering