English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

jQuery Miscellaneous get() Method

jQuery Miscellaneous Methods

The get() method retrieves the DOM element specified by the selector.

Syntax:

$ (selector).get(index)

Example

Get the name and value of the first segment (index 0):

$ (document).ready(function() {
  let x = $("p").get(0);
  $("div").text(x.tagName + " : " + x.innerHTML);
});
Test See‹/›

Display the tag name of the click element:

$("*", document.body).click(function(event){
  event.stopPropagation();
  let domElement = $(this).get(0);
  $("span:first").text("Clicked - " + domElement.nodeName);
});
Test See‹/›

Parameter Value

ParameterDescription
index(Optional) An integer starting from zero indicating the element to be retrieved

jQuery Miscellaneous Methods