• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to get Events associated with DOM elements ?

 
Mohit J Kumar
Ranch Hand
Posts: 33
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi everyone,

I have an HTML document.
It is possible to get the events associated with every Element in a particular FORM element in the document using javascript.

var element = document.forms[i].elements[j];

This way I can get j th element in i th form, But can I get the event associated with the element.
There can be any number of elements in a form.I am using IE 8.

I am a total beginner in javascript/javascript event handling.


Thanks
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"get the events associated"

What do you mean by events?

Eric
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64958
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Events aren't associated with elements until they are triggered. You'll need to explain what you are after in much better detail.
 
Mohit J Kumar
Ranch Hand
Posts: 33
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Actually I was trying to serialize HTML DOM into XML.

what I did to do this was :



What I am getting from this is an XML :




Now Suppose I have :

<input tabindex="7" name="button" type="button" class="button"
style="width:100;height:30" Value="Continue" onclick='login()' />

All I want to do now is to get onClick in my XML or any event associated like onBlur() etc.


Thanks
 
Eric Pascarello
author
Rancher
Posts: 15385
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are writing XML why?

Eric
 
Mohit J Kumar
Ranch Hand
Posts: 33
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well I don't want to mess with my javascript code every time I need to change/manipulate my DOM.
I am planning to create a tool which will create an HTML DOM out of this XML file.
So here I will do it in three steps.

Step 1 : Get HTML DOM (which I need to manipulate) serialized to well formatted XML file.
Step 2 : Make changes in XML.
Step 3 : Use the XML to reflect the changes in the HTML DOM.

<input tabindex="7" name="button" type="button" class="button"
style="width:100;height:30" Value="Continue" onclick='login()' />

Now in Step1 I am not able to get onclick='login()' information in my XML.
There may be other events like this e.g, onBlur, onFocus etc.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic