Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Javascript - DOM node represented as object

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?

Name: Anonymous 2014-02-01 15:38

install BSD/Gentoo

Name: Anonymous 2014-02-01 15:58

never mind friends.
I found the solution to the problem myself.
Oh, and BSD/Gentoo is shit.

Name: Anonymous 2014-02-06 8:08

Why not just use jQuery or some similar DOM library?

Name: Cudder !MhMRSATORI!fR8duoqGZdD/iE5 2014-02-06 8:34

A DOM node is an object in JS already. WTF are you trying to do?

Name: Anonymous 2014-02-06 10:56

'>Object-oriented programming

Name: Anonymous 2014-02-06 18:58

implying js even has objects

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List