Home > Web Front-end > JS Tutorial > Example of usage of get() method in jQuery_jquery

Example of usage of get() method in jQuery_jquery

WBOY
Release: 2016-05-16 16:24:17
Original
1044 people have browsed it

The example in this article describes the usage of the get() method in jQuery. Share it with everyone for your reference. The specific analysis is as follows:

This method can return an array of all DOM elements in the matching collection or a DOM element with a specified index.
Index values ​​start from 0.

Description: As can be seen from the above definition, this method can convert jQuery objects into DOM objects.

Grammar structure 1:

Copy code The code is as follows:
$(selector).get()

Without parameters, an array of all matching DOM elements will be obtained.

Example code:

Copy code The code is as follows:






get() function-Script Home






  • ASP Zone

  • jsp area

  • php area

  • ASP.NET Zone



  • DIV CSS Zone

  • Jquery Zone

  • javascript area

  • html area





By using $(".zhuanqu").get(), you can get the array of li elements with the class name zhuanqu. After reading the example, you may ask why $() is needed outside. This is because the DOM object obtained through the get() method needs to be converted into a jQuery object before the CSS() method can be used.

Grammar structure 2:

Copy code The code is as follows:
$(selector).get(index)

With parameters, obtains a specified matching element in the array of all matching DOM elements.

Example code:

Copy code The code is as follows:






get()函数-脚本之家





 

       
  • ASP专区

  •    
  • jsp专区

  •    
  • php专区

  •    
  • ASP.NET专区

  •  

 

       
  • DIV CSS专区

  •    
  • Jquery专区

  •    
  • javascript专区

  •    
  • html专区

  •  




里面的参数是要获取的DOM对象数组中DOM对象的索引,索引是从零开始的。

希望本文所述对大家的jQuery程序设计有所帮助。

Related labels:
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