The selector property usage instance of the jQuery object

  • 2020-05-09 18:12:04
  • OfStack

This example demonstrates the use of selector properties for jQuery objects. Share with you for your reference. The specific analysis is as follows:

This property returns the original selector passed to jQuery, which selector jQuery used to match the current element.

The selector property can be used in conjunction with context to accurately detect selector queries.

Grammatical structure:


Example code:

<!DOCTYPE html>
<meta charset=" utf-8">
<meta name="author" content="//" />
<title> The home of the script </title>
<script type="text/javascript" src="mytest/jQuery/jquery-1.8.3.js"></script>
<script type="text/javascript">
    $("div").text(" The original selector is: "+$("ul li").selector);
  <button id="btn"> Click to view an example </button>

The above code USES the selector attribute to return which selector $() matches the element with.

I hope this article has helped you with the jQuery programming.

Related articles: