Home > Web Front-end > JS Tutorial > jQuery Learning 2 Selector Instructions_jquery

jQuery Learning 2 Selector Instructions_jquery

WBOY
Release: 2016-05-16 18:35:23
Original
1210 people have browsed it
1. Use basic CSS selectors:
a: Match all link elements.
#*: Matches elements with id *
.*: Matches elements with CSS class *
a#*id.*class: Matches links with id *id and has CSS class *class element.
The above is how it is written in CSS, wrapped in $("") in jQuery, such as: jQuery("p a.Class")

Use sub-selectors, container selectors and attribute selection Take the following as an example:
Copy code The code is as follows:



If you want to select all the links in the first list
  • , you should use the sub-selector: ul.myList > ; li >a and not like this ul.myList li a because all these links are descendant nodes of list
  • elements.
    Child selector: parent node and direct child node are pointed to the right separated by brackets (>).
    Attribute selector: Wrap elements that match specific content. For example, select a link containing an href value starting with http://: a[href^=http://]
    input[type=text]: Match all elements
    whose type attribute is text div[title=^my]: Matches all
  • source:php.cn
    Statement of this Website
    The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
    Popular Tutorials
    More>
    Latest Downloads
    More>
    Web Effects
    Website Source Code
    Website Materials
    Front End Template