title: How to get Events associated with DOM elements?
body: <p>I have an HTML document.<br />
  It is possible to get the <strong>events</strong> associated with every Element in a particular FORM element in the document using <strong>JavaScript</strong>.</p>
  <pre><code>var element = document.forms[i].elements[j];
  </code></pre>
  <p>This way I can get <code>j</code>th element in <code>i</code>th form, But can I get the event associated with the element.<br>
  There can be any number of elements in a form. I am using <b>IE 8</b>.<br></p>
  <hr />
  <br>
  **EDIT :**
  <br>
  Actually I was trying to serialize HTML DOM into XML.
  <p>what I did to do this was :</p>
  <pre><code>createXML : function() {
          
          objSerializeDOM.msg += &quot;&quot;;
          objSerializeDOM.msg += &quot;&lt;?xml version='1.0' encoding='UTF-8'?&gt;\n\n&quot;;
          // Get all the forms in a document.
          var forms = document.forms;
  
          for ( var i = 0; i &lt; forms.length; i++) {
              // Get all the elements on per form basis.
              elements = document.forms[i].elements;
              objSerializeDOM.msg += &quot;&lt;FORM name=\&quot;&quot; + forms[i].name + &quot;\&quot; method=\&quot;&quot;
                      + forms[i].method + &quot;\&quot; action=\&quot;&quot; + forms[i].action + &quot;\&quot;&gt;\n\n&quot;;
              for ( var j = 0; j &lt; elements.length; j++) {
                  objSerializeDOM.msg += &quot;    &lt;&quot; + elements[j].tagName + &quot;  type=\&quot;&quot;
                          + elements[j].type + &quot;\&quot;&quot; + &quot;  name=\&quot;&quot;
                          + elements[j].name + &quot;\&quot;&quot; + &quot;   Value =\&quot;&quot;
                          + elements[j].value + &quot;\&quot;  /&gt;\n&quot;;
              }
              alert(document.forms[i].elements[1].event);
          }
          objSerializeDOM.msg += &quot;\n\n&lt;/FORM&gt;\n\n&quot;;
          alert(objSerializeDOM.msg);
          objSerializeDOM.writeToFile(objSerializeDOM.msg);
      }
  </code></pre>
  <p>What I am getting from this is an XML :</p>
  <pre><code>&lt;?xml version='1.0' encoding='UTF-8'?&gt;
  
  &lt;FORM name=&quot;loginForm&quot; method=&quot;post&quot; action=&quot;/sigma/login.do;jsessionid=E6509E7BA55573AA5386274ABB93F718&quot;&gt;
  
      &lt;INPUT  type=&quot;hidden&quot;  name=&quot;message&quot;   Value =&quot;&quot;  /&gt;
      &lt;INPUT  type=&quot;hidden&quot;  name=&quot;userAction&quot;   Value =&quot;&quot;  /&gt;
      &lt;INPUT  type=&quot;text&quot;  name=&quot;userId&quot;   Value =&quot;&quot;  /&gt;
      &lt;INPUT  type=&quot;password&quot;  name=&quot;passwd&quot;   Value =&quot;&quot;  /&gt;
      &lt;INPUT  type=&quot;button&quot;  name=&quot;button&quot;   Value =&quot;Continue&quot;  /&gt;
  
  
  &lt;/FORM&gt;
  </code></pre>
  <p>Now suppose I have:</p>
  <pre><code>&lt;input tabindex=&quot;7&quot; name=&quot;button&quot; type=&quot;button&quot; class=&quot;button&quot;
                  style=&quot;width:100;height:30&quot; Value=&quot;Continue&quot; onclick='login()' /&gt;
  </code></pre>
  <p>All I want to do now is to get <code>onClick</code> in my XML or any event associated like <code>onBlur()</code> etc.</p>