Remove spaces at the beginning and end of a string. This document describes how to remove spaces in multiple ways, for more information, see remove spaces at the beginning and end of a string.
JQuery code:
The Code is as follows:
$. Trim ("hello, how are you? ");
Jquery cyclically reads the checkbox Value
The Code is as follows:
The Code is as follows:
$ ("Input [type = checkbox] [checked]"). each (function () {// Since multiple check boxes are selected, You can output them cyclically.
Alert ($ (this). 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 () $ ("# "). both text () and text () are values. The values are html,
Retrieve text
Method 1:
The Code is as follows:
Watermarks ('regionid').css ('display', 'None ');
Watermarks ('regionid').css ('display', 'block ');
Method 2:
The Code is as follows:
$ ('# Id'). hide ();
$ ('# Id'). show ();
Radio button group, name = "sex ".
The Code is as follows:
Male
Female
Unknown
1. Obtain the value selected by radio.
The Code is as follows:
$ ('Input: radio [name = sex]: checked'). val ();
2. Select the radio button (Male ).
The Code is as follows:
$ ('Input: radio [name = sex]: nth (0) '). attr ('checked', true );
Or
The Code is as follows:
$ ('Input: radio [name = sex] ') [0]. checked = true;
3. Select the radio button (Female ).
The Code is as follows:
$ ('Input: radio [name = sex]: nth (1) '). attr ('checked', true );
Or
$ ('Input: radio [name = sex] ') [1]. checked = true;
4. Select the radio button (Unknown ).
The Code is as follows:
$ ('Input: radio [name = sex]: nth (2) '). attr ('checked', true );
Or
$ ('Input: radio [name = sex] ') [2]. checked = true;
5. Reset the radio button.
The Code is as follows:
$ ('Input: radio [name = sex] '). attr ('checked', false );