Third, jquery selector

Source: Internet
Author: User

Attention:

jquery gets the object forever, even if the element is not on the page

Cannot judge if ($ (' #tt ')) {}

The IF ($ (' #tt ') should be judged based on the length of the element. Length > 0) {}

or convert to Dom to determine if ($ (' #tt ') [0]) {}


First, the basic selector

The basic selector is the most commonly used selector in jquery and is the simplest selector for finding DOM elements through element Id,class, tag names, and so on.

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M01/37/C8/wKiom1Ov4wzTaKNhAAFZs1AjZjo953.jpg "title=" 23411234.JPG "alt=" Wkiom1ov4wztaknhaafzs1ajzjo953.jpg "/>


Second, level selector


650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/37/C8/wKiom1Ov4w2S_bG6AAIV7RB4Ft0451.jpg "title=" 325453453.JPG "alt=" Wkiom1ov4w2s_bg6aaiv7rb4ft0451.jpg "/>



Third, filter selector

1. Basic Filter Selector

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/37/C7/wKioL1Ov4t-hvwF3AAVOHFdzM0Q176.jpg "title=" 234234234.png "alt=" Wkiol1ov4t-hvwf3aavohfdzm0q176.jpg "/>



2. Content Filter Selector


650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M01/37/C8/wKiom1Ov4w7zb9SnAAFRsJuhpJU468.jpg "title=" content filtering. JPG "alt=" Wkiom1ov4w7zb9snaafrsjuhpju468.jpg "/>



3. Visibility Filter Selector

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M02/37/C7/wKioL1Ov4t-QoOrHAADvVrvLYmk979.jpg "title=" visibility filtering. JPG "alt=" Wkiol1ov4t-qoorhaadvvrvlymk979.jpg "/>


4. Attribute Filter Selector

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/37/C7/wKioL1Ov4uDCpR4PAAJfIf-62Rg750.jpg "title=" attribute filtering. JPG "alt=" Wkiol1ov4udcpr4paajfif-62rg750.jpg "/>


5, sub-element filter Selector

650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/37/C7/wKioL1Ov5OixLbAtAAYHRKxF9zk126.jpg "title=" Untitled. png "alt=" wkiol1ov5oixlbataayhrkxf9zk126.jpg "/>


6. Form object Property Filter Selector

650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/37/C8/wKiom1Ov4w7QK8CbAAFSR7MfyhY311.jpg "title=" form elements. JPG "alt=" Wkiom1ov4w7qk8cbaafsr7mfyhy311.jpg "/>


Four, form selector

650) this.width=650, "src=" http://s3.51cto.com/wyfs02/M01/37/C7/wKioL1Ov4t-A_KQpAAJapdcODaU844.jpg "title=" form selection. JPG "alt=" Wkiol1ov4t-a_kqpaajapdcodau844.jpg "/>


Five, attention to special symbol processing

<div id= "id#b" >bb</div>

<div id= "Id[1" >cc</div>


$ (' #id #b ')

$ (' #id [1] ') cannot be obtained

To escape

$ (' #id \ #b ')

$ (' #id \\[1\\] ')


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.