Skip to content
geeksforgeeks
  • Tutorials
    • Python
    • Java
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
    • Practice Coding Problems
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • HTML Tutorial
  • HTML Exercises
  • HTML Tags
  • HTML Attributes
  • Global Attributes
  • Event Attributes
  • HTML Interview Questions
  • HTML DOM
  • DOM Audio/Video
  • HTML 5
  • HTML Examples
  • Color Picker
  • A to Z Guide
  • HTML Formatter
Open In App

HTML DOM isSameNode() Method

Last Updated : 09 Jun, 2023
Comments
Improve
Suggest changes
Like Article
Like
Report

The isSameNode() method checks whether the two nodes are the same or not. This method is different from isequalNode(), where two different nodes can be equal but not the same, here the same node means that they are referencing the same object. 

Syntax:

node.isSameNode(othernode)

Parameters: The "othernode" parameter is required in this function. 

Return Value: Returns a Boolean value, if matches then True else False. 

Example: In this example, we will use isSameNode() method

HTML
<!DOCTYPE html> <html> <head>     <title>         HTML | DOM isSameNode() Method     </title>      <!--script to check if nodes are same-->     <script>         function isequal() {             let out = document.getElementById("result");             let divele = document.getElementsByTagName("div");             out.innerHTML += "element 1 equals element 1: " +                 divele[0].isSameNode(divele[0]) + "<br/>";             out.innerHTML += "element 1 equals element 2: " +                 divele[0].isSameNode(divele[1]) + "<br/>";             out.innerHTML += "element 1 equals element 3: " +                 divele[0].isSameNode(divele[2]) + "<br/>";         }     </script> </head>  <body>     <h3>Comparing the div elements.</h3>      <!-- 3 div elements-->     <div>GeeksforGeeks</div>     <div>GfG</div>     <div>GeeksforGeeks</div>     <button onclick="isequal()">Check</button>      <!-- Result-->     <p id="result"></p> </body> </html> 

Output: 

 

Supported Browsers: The browser supported by DOM isSameNode() Method are listed below:

  • Google Chrome 1
  • Edge 12
  • Internet Explorer 9
  • Opera 12.1
  • Safari 3
  • Firefox 48

P

ProgrammerAnvesh
Improve
Article Tags :
  • Web Technologies
  • HTML
  • Web technologies
  • HTML-DOM

Similar Reads

    HTML DOM KeyboardEvent code Property
    The keyboardEvent code property in HTML represents a physical key on the keyboard. It is used to return the key that triggers the event. Syntax: event.code Return Value: It returns a string that represents which key is pressed. Example 1: With KeyDown Event HTML <html> <head> <title
    2 min read
    HTML DOM lastChild Property
    The DOM lastChild property is used to return the last child of the specified node. It returns the last child nodes as text, comment, or element nodes (depend on which occurs at last). It is a read-only property. Syntax: node.lastChild Return Value: It returns a node object which represents the last
    2 min read
    HTML DOM Aside Object
    The DOM Aside Object is used to represent the HTML <Aside> element. The Aside element is accessed by getElementById(). The aside Element is new in HTML 5. Syntax: document.getElementById("ID"); where "id" is the ID assigned to the aside tag. Example 1: In this article, we will learn DOM Aside
    2 min read
    HTML DOM Bold Object
    The DOM Bold Object is used to represent the HTML <b> element. The bold element is accessed by getElementById(). Syntax: document.getElementById("ID"); Where "id" is the ID assigned to the "b" tag. Example 1: In this example, we will use HTML DOM Bold Object HTML <!DOCTYPE html> <html
    1 min read
    HTML DOM blur() Method
    The DOM blur method is used to remove the keyboard focus from the current element and also give focus with the help of the focus() method. We can apply the blur to any element and enable it by doing some operations. For example, we can blur to text-box by clicking a button. Syntax: Object.blur() Exa
    1 min read
    HTML DOM Body Object
    The DOM Body Object is used to represent the HTML <Body> element. The Body element is accessed by getElementByTagName(). It can also be accessed by using a document.body object. Object Properties: Alink: It is used to sets or return the color of the active link in a Document.background: It is
    2 min read
    HTML DOM Blockquote Object
    The DOM Blockquote Object is used to represent the HTML <Blockquote> element. The Blockquote element is accessed by getElementById(). Syntax document.getElementById("id"); Where "id" is the ID assigned to the blockquote tag. Property Value cite: It is used to Sets or return the value of the ci
    2 min read
    HTML DOM Bdo Object
    The DOM Bdo Object is used to represent the HTML <Bdo> element. The Bidirectional element is accessed by getElementById(). Properties: It has a dir attribute which is used to set or return the text direction of an element. Syntax: document.getElementById("GFG"); Where "GFG" is the ID assigned
    2 min read
    HTML DOM firstElementChild Property
    The HTML DOM firstElementChild Property will return the first child of any node PreRequisites DOM (Document Object Model) Parameters: No parameters are required. Return value: The values returned by firstElementChild property are the following: A Node object: Representing the first child element of
    1 min read
    HTML DOM isEqualNode() Method
    The HTML DOM isEqualNode() method checks whether the two nodes are equal or not. These nodes are considered equal if they are of the same type, having the same characteristics and the same attributes. The attributes do not have to be in the same order. Syntax: node.isEqualNode(othernode) Parameters:
    2 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences