JQuery removes spaces between the start and end of a string (implemented in multiple methods) _ jquery

Source: Internet
Author: User
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 );

Related Article

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.