Common jquery code 1

Source: Internet
Author: User

// Select the value of the selected radio
$ ("Input [name = 'Radio _ name'] [checked]"). Val ();

// Set radio to the selected status based on the value.
$ ("Input [name = 'Radio _ name'] [value = 'value of radio to be selected '"). ATTR ("checked", true );

// Select the set of the selected checkbox element. If you want to get the value, you need to traverse the set.
$ ("Input [name = 'checkbox _ name'] [checked]");

// Obtain the value by traversing the set of the selected checkbox Element
$ ("Input [name = 'checkbox _ name'] [checked]"). each (function () {arrchk + = This. value + ',';});

// Obtain the status of a checkbox (true/false if it is selected or not)
$ ("# Checkbox_id"). ATTR ("checked ");

// Set the status of a checkbox to selected (checked = true)
$ ("# Checkbox_id"). ATTR ("checked", true );

// Set the status of a checkbox to deselected (checked = false)
$ ("# Checkbox_id"). ATTR ("checked", false );

$ ("Input [name = 'checkbox _ name']"). ATTR ("checked", $ ("# checkbox_id"). ATTR ("checked "));

// Event triggered when the object text_id obtains the focus
$ ("# Text_id"). Focus (function () {// code ...});

// Event triggered when the object text_id loses focus
$ ("# Text_id"). Blur (function () {// code ...});

// Set the vlaue value of the text box to the selected status
$ ("# Text_id"). Select ();

 

// ListBox get the selected value

VaR text = $ ("# lbroom option: Selected"). Text ();
VaR value = $ ("# lbroom option: Selected"). Val ();

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.