Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Assign A New Method To Every Node

<head>
	  <script>
 function add()
		  {
			  Node.prototype.d = function(){
			  console.log(this.textContent)	
};
let a =			  document.getElementById("a");
let b =			  document.getElementById("b");
a.d();
b.d();
}
      </script>  
  </head>
  <body>
<button id="btn" onclick="add()">Press </button>
<div id="a">aaaa</div>
<div id="b">bbbb</div> 
</body>
 
PREVIOUS NEXT
Tagged: #Assign #A #New #Method #To #Every #Node
ADD COMMENT
Topic
Name
9+7 =