title: How can I get DOM elements attributes name on a click, by JavaScript supposing the click can be anywhere on the page?
body: <p>Lets say I have html page, when ever user clicks on the page an event should occur on the press of a user click it should save all attributes behind that elements.</p>
  
  <pre><code>&lt;head&gt;
  &lt;script&gt;
  document.addEventListener('click', function(e) {
      e = e || window.event;
      var target = e.target || e.srcElement,
          text = target.textContent || target.innerText;   
  }, false);
  &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;p style="color: green"&gt;
  The content above was created with JavaScript.&lt;br&gt;
  This content is created with &lt;b&gt;HTML&lt;/b&gt;.&lt;br&gt;
  You can edit JavaScript and HTML in the left part of the page
  and click "&lt;b&gt;Run code&lt;/b&gt;" to view results in the right part of the page.
  &lt;/p&gt;
  &lt;div id="dev1"&gt;
  &lt;p style="color: green"&gt;
  The content above was created with JavaScript.&lt;br&gt;
  Username : &lt;input type="text" name="txtusername" id="username" &gt; &lt;br&gt;&lt;br&gt;
  Password : &lt;input type="Password" name="password" id="passname" &gt;
  &lt;/p&gt;
  &lt;/div&gt;
  &lt;b&gt;LESSON 4: CALL A JAVASCRIPT FUNCTION:&lt;/b&gt;
  &lt;/body&gt;
  &lt;/html&gt;```
  </code></pre>