Home  >  Article  >  Web Front-end  >  JQuery study notes selector three_jquery

JQuery study notes selector three_jquery

WBOY
WBOYOriginal
2016-05-16 18:49:27933browse

复制代码 代码如下:





无标题文档






h1


h2


  • li1
      1

      2

      3

      4


  • li2
      5

      6


  • li3


  • checkbox1
    checkbox2


    显示第一个ul节点的值
    显示最后一个ul节点的值
    显示未选择中checkbox的ID
    显示索引为偶数的ul内容
    显示索引为奇数的ul内容
    显示索引为3的ul内容
    显示索引大于3的ul内容
    显示索引小于3的ul内容
    显示页面标题内容


    Result:







    This section doesn’t seem to have any extracurricular knowledge points, ha, let’s get to the point now
    1.$("TabName:first")
    Description: The first node of a certain node can be obtained, such as There are 6 uls in the example. Use $("ul:first") to get the first ul node
    Return value: Element;
    2.$("TabName:Last")
    Description : Similar to the previous usage, the only difference is that this method is used to get the last node
    Return value: Element;
    3.$("TabName:not(:attribute)")
    Description: This method Some simple selector filtering can be implemented. For example, $("input:not(:checked)") selects unselected checkbox elements. This method is still in practice. It seems that it can only select bool values. Filter on the attribute, which in the example is equivalent to selecting the input checked to false.
    Return value: Array(Element);
    4.$("TabName:even")
    Description: Used to obtain the set of even index nodes of a certain node. One thing to emphasize here, here The index starts from 0, so in the example aEven obtains the 1st, 3rd, and 5th ul nodes after clicking
    Return value: Array(Element);
    5.$("TagName:odd" )
    Description: Similar to the previous method, the only difference is that this obtains a set of odd nodes.
    Return value: Array(Element);
    6.$("TagName:eq(index)")
    Description: The node used to obtain the index index position in a certain node collection
    Return Value: Array(Element);
    7.$("TagName:gt(index)")
    Description: Used to obtain a node collection with an index greater than index in a certain node collection
    Return value: Array (Element);
    8.$("TagName:lt(index)")
    Description: Used to obtain a node set whose index is less than index in a certain node set
    Return value: Array(Element) ;
    9.$(":header")
    Description: used to obtain the collection of title nodes such as h1, h2, h3 in the page
    Return value: Array(Element);
    Statement:
    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