Skip to content
Related Articles
Get the best out of our app
GFG App
Open App
geeksforgeeks
Browser
Continue

Related Articles

jQuery | context Property

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

The DOM node context contains original passed to jQuery(), Which is a dom node context if there is no node passed then context will be the document.

Syntax:

context

Examples:




<!DOCTYPE html>
<html>
  
<head>
    <meta charset="utf-8">
    <title>
      context demo
  </title>
    <script src=
            "https://code.jquery.com/jquery-1.10.2.js">
  </script>
    
  <script>
    $(document).ready(function() {
        $("button").click(function() {
            $("ul")
             .append("<li>" + $("ul")
                   .context + "</li>")
                 
             .append("<li>" + $("ul", document.body)
                   .context.nodeName + "</li>");
            });
        });
    </script>
</head>
  
<body>
  
    <h1 style="color:green;"
GeeksForGeeks 
</h1> Context:
    <ul></ul>
    <button>Click</button>
  
</body>
  
</html>


Output:
Before Click:

After Click:

Note: The context property was removed in jQuery version 3.0.


My Personal Notes arrow_drop_up
Last Updated : 27 Mar, 2019
Like Article
Save Article
Similar Reads
Related Tutorials