Home > Web Front-end > JS Tutorial > body text

jquery form filter

无忌哥哥
Release: 2018-06-29 11:29:36
Original
1304 people have browsed it

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')
Copy after login

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')
Copy after login

. 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')
Copy after login

: 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')
Copy after login

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')
Copy after login

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')
Copy after login

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')
Copy after login

Select only the text box:type="text"

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

Select only the submit button

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

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

source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!