JavaScript Example (Program)
Learn Details

1. what is isEqualNode ?

Ans : यइसके द्वारा किसी दो element को compare करके Boolean value को return करता है।

What does compare ?

  • Element
  • Text Node
  • Attribute
  • Attribute Value

comparison by isEqualNode

Syntax :

element1.isEqualNode(element2)

Example

HTML Code


   <html>	
	<!--head section-->
   <head>
      <title>Official Website Teach Coders</title>
		  <meta name="description" content="Teach Coders" />
		  <meta name="keywords" content="Teach Coders" />
		 <link rel="stylesheet" type="text/css" href="style.css">
   </head>

   <body>

    <div class="box1">
      <ul>
        <li>HTML</li>
        <li class="teach">Css</li>
        <li>css</li>
        <li>javascript</li>
        <li>Advance javascript</li>
        <li>TypeScript</li>
        <li>Angular</li>
        <li>Node</li>
        <li>Mango</li>
        <li>Express</li>
      </ul>
    </div>

      <div class="box2">
      <ul>
        <li>Express</li>
        <li>Mango</li>
        <li>HTML</li>
        <li class="teach">Css</li>
        <li>javascript</li>
        <li>Advance javascript</li>
        <li>TypeScript</li>
        <li>Angular</li>
        <li>Node</li>
        <p>HTML</p>
       
       
      </ul>
    </div>

</script>


   </body>
</html>
   
  
-----------------------------------------------
 EXAMPLE 1 : compare with element (false return)
 -----------------------------------------------
<script>
  var element1 = document.querySelector(".box1 ul").children[0];
  var element2 = document.querySelector(".box2 ul").children[0];
  var comp = element1.isEqualNode(element2);
  console.log(comp)
</script>

-----------------------------------------------
 EXAMPLE 2 : compare with element (true return)
-----------------------------------------------
<script>
    var element1 = document.querySelector(".box1 ul").children[0];
    var element2 = document.querySelector(".box2 ul").children[2];
    var comp = element1.isEqualNode(element2);
    console.log(comp)
</script>

-----------------------------------------------
 EXAMPLE 3 : compare with element & his attribute (false return)
-----------------------------------------------
<script>
  var element1 = document.querySelector(".box1 ul").children[2];
  var element2 = document.querySelector(".box2 ul").children[3];
  var comp = element1.isEqualNode(element2);
  console.log(comp);
</script>

-----------------------------------------------
 EXAMPLE 4 : compare with element & his attribute (true return)
-----------------------------------------------
<script>
  var element1 = document.querySelector(".box1 ul").children[1];
  var element2 = document.querySelector(".box2 ul").children[3];
  var comp = element1.isEqualNode(element2);
  console.log(comp)
</script>



 
 
  
  

Css Code


<style>
     div{
           width:300px;
           float:left;
           margin:15px;
    }
    ul li{
          padding:4px;
          font-size:18px;
    }
    .box1{   
          background:#e2f6fd;
          border:solid 2px #305461;
    }
    .box2{
          background:#ffe6e0;
          border:solid 2px #a26a5d;
    }
</style>