JQuery removes spaces at the beginning and end of a string.
Source: Internet
Author: User
Removes spaces at the beginning and end of a string. JQuery code: $. trim (& quot; hello, howareyou? & Quot;); the Code for copying the checkbox value read cyclically by jquery is as follows: $ (& quot; input [typecheckbox] [checked] & quot ;). each (function () {// the check box is generally selected. removes spaces at the beginning and end of a string. JQuery code: $. trim ("hello, how are you? "); Jquery cyclically reads the checkbox value and copies the Code as follows: $ (" input [type = checkbox] [checked] "). each (function () {// Since multiple check boxes are selected, You can output alert ($ (this) cyclically ). val () ;}); $ ("# "). the value of val ("1") id as A is 1 in jQuery. When assigning values, it is passed as A parameter to the function, which is different from js alone, like $ ("# A" ).html ("1") $ ("# "). all text ("1") values are assigned $ ("# A" ).html () $ ("# "). all text () values are values. Take html and use text. Method 1: Fill ('your id'}.css ('display', 'None'); fill ('your id'}.css ('display', 'block'); Method 2: $ ('# id '). hide (); $ ('# id '). show (); radio button group, name = "sex ". Male Female Unknown1. obtain the value selected by radio. $ ('input: radio [name = sex]: checked '). val (); 2. select the radio button (Male ). $ ('input: radio [name = sex]: nth (0 )'). attr ('checked', true); or $ ('input: radio [name = sex] ') [0]. checked = true; 3. select the radio button (Female ). $ ('input: radio [name = sex]: nth (1 )'). attr ('checked', true); or $ ('input: radio [name = sex] ') [1]. checked = true; 4. select the radio button (Unknown ). $ ('input: radio [name = sex]: nth (2 )'). attr ('checked', true); or $ ('input: radio [name = sex] ') [2]. checked = true; 5. reset the radio button. $ ('input: radio [name = sex] '). attr ('checked', false );
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.