Name: Anonymous 2014-02-01 15:35
Hello friends.
I have spent the last few hours trying to think of a way to create a representaion of a DOM node as a javascript object. What I mean:
Consider the simple following node
[code]<div data-name='div1'>
<span data-name='span1'></span>
<span data-name='span22'></span>
<div data-name='div2'>
<span></span>
</div>
</div>
I want to create an object that
a)would contain the elements of the node with a 'data-name' attribute,
b)maintain the hierarchy of the dom node and set the corresponding elements to the objects properties
So that if for example I was to do something like
object.div1.span1 it would return the <span data-name='span1'></span>
is his possible?
I have spent the last few hours trying to think of a way to create a representaion of a DOM node as a javascript object. What I mean:
Consider the simple following node
[code]<div data-name='div1'>
<span data-name='span1'></span>
<span data-name='span22'></span>
<div data-name='div2'>
<span></span>
</div>
</div>
I want to create an object that
a)would contain the elements of the node with a 'data-name' attribute,
b)maintain the hierarchy of the dom node and set the corresponding elements to the objects properties
So that if for example I was to do something like
object.div1.span1 it would return the <span data-name='span1'></span>
is his possible?