Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the most commonly used methods of jquery

2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article introduces the relevant knowledge of "what are the most commonly used methods of jquery". In the operation of actual cases, many people will encounter such a dilemma, so let the editor lead you to learn how to deal with these situations. I hope you can read it carefully and be able to achieve something!

1. Basic selector

1. Tag selector (element selector)

* Syntax: $("html tag name") to get all elements that match the tag name

2. Id selector

* Syntax: $("attribute value of # id") to get the element that matches the specified id attribute value

3. Class selector

* Syntax: $("attribute value of .class") to get the element that matches the specified class attribute value

4. Union selector:

Syntax: $("selector 1, selector 2..." Get all the elements selected by multiple selectors

two。 Hierarchical selector

1. Descendant selector

* Syntax: $("A B") Select all B elements inside An element

two。 Subselector

* Syntax: $("A > B") Select all B child elements within element A

3. Attribute selector

1. Attribute name selector

* Syntax: $("A [attribute name]") contains the selector for the specified attribute

two。 Attribute selector

* Syntax: $("A [attribute name = 'value']") contains a selector in which the specified attribute is equal to the specified value

3. Compound attribute selector

* Syntax: $("A [attribute name = 'value'] [] …" A selector that contains multiple attribute conditions

4. Filter selector

1. First yuan Qin selector

* Syntax:: first gets the first element of the selected element

two。 Tail element selector

Syntax:: last gets the last Yuan Qin in the selected element

3. Non-Yuanqin selector

Syntax:: not (selector) does not include elements of the specified content

4. Even selector

Syntax:: even even number, counting from 0

5. Odd selector.

Syntax:: odd odd, counting from 0

I

6. Equal to index selector

* Syntax:: eq (index) specifies the index element

7. Greater than index selector

* Syntax:: gt (index) is greater than the specified index element

8. Less than index selector

* syntax:: lt (index) is less than the specified index element

5. Form filter selector:

1. Available element selector

*

Syntax:: enabled to get available elements

two。 Element selector is not available.

*

Syntax:: disabled to get unavailable elements

3. Select selector

* Syntax:: checked gets the elements selected in the radio / check box

4. Select the selector.

Syntax:: selected gets the elements selected in the drop-down box

DOM operation

1. Content operation html (): gets / sets the tag body content of the element

Content-- > content text (): get / set the element's tag body plain text content-- > content val (): get / set the element's value attribute value

two。 Attribute operation

1. General attribute action attr (): get / set the attribute of the element removeAttr (): delete the attribute

3. Prop (): get / set the attribute of the element removeProp (): delete the attribute

The difference between attr and prop?

1. If you are manipulating inherent attributes of an element, it is recommended that you use prop

two。 If you are manipulating attributes that are customized by the element, it is recommended that you use attr

two。 Operate addClass () on class attribute: add class attribute value removeClass (): delete class attribute value toggleClass (): toggle class attribute

This is the end of the content of "what are the most commonly used methods of jquery". Thank you for reading. If you want to know more about the industry, you can follow the website, the editor will output more high-quality practical articles for you!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report