JQuery operation basic control method Example Analysis _ jquery

Source: Internet
Author: User
This article mainly introduces the basic control methods for jQuery operations, and analyzes common techniques such as jQuery controls for style, ID acquisition, traversal, and attribute operations based on examples, for more information about jQuery's basic control operations, see the following example. We will share this with you for your reference. The details are as follows:

1. Obtain the control based on the style class of the control.

The Code is as follows:

$ (". ClassName") ...... // className indicates the control style.

2. Obtain the control based on its ID.

The Code is as follows:

$ ("# Id ")......

3. Obtain the control based on the control name

$("input[name='objName']")....../*$("check[name='objName']")......*/$("[name=objName]:checkbox")......$("select[name='objName']")......

4. traverse a group of controls

$ (". ClassName "). each (function () {$ (this ). attr ("title", "click to maintain"); // $ (this) Get the object Currently traversed}); for (var I = 0; I <$ (". className "). length; I ++) {$ (". className: eq ("+ I + ")"). attr ("title", "click to maintain ");}

5. Operation Control CSS style

$ ("# ObjId" ).css ("attribute name"); // obtain the CSS attributes of the current object, such as: $ ("# userName" ).css ("color "); returns the userName color $ ("# objId" ).css ("attribute name", "value"); // sets the CSS attribute for the current control, for example: $ ("# userName" ).css ("color", "# FFCCFF"); set the userName color to # FFCCFF

6. Common Properties of the Operation Control

$ ("Input [name = 'age']"). attr ("property name"); // get the basic property of the control $ ("input [name = 'age']"). attr ("attribute name", "value"); // you can specify the basic attributes of a widget, for example, $ ("# input [name = 'age']"). attr ("size", "30 ");

I hope this article will help you with jQuery programming.

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.