javascript - What's the difference between Node/Element/Object? -


it said, in many many places, they're both same thing. when start explaining refer each 1 of them differently without giving clear explanation what's difference?

please try specific possible i'm still learning js not great yet. :)

a node interface number of dom types inherit, , allows these various types treated (or tested) similarly. ref: https://developer.mozilla.org/en-us/docs/web/api/node

the element interface represents object of document. interface describes methods , properties common kinds of elements. specific behaviors described in interfaces inherit element add additional functionality. example, htmlelement interface base interface html elements, while svgelement interface basis svg elements. ref: https://developer.mozilla.org/en-us/docs/web/api/element

an object may represent anything. objects have properties, describe them, , methods actions can performed on them.

putting together:

you can create dom node in web page so:

var node=document.createtextnode('a node'); 

then can create paragraph element:

var p=document.createelement('p'); 

attach node paragraph:

p.appendchild(node); 

you may reference node , element objects:

p.classname='description';  // set class property of paragraph 'description';  p.setattribute('data-item', '8');  // add attribute named data-item value of 8 

Comments

Popular posts from this blog

c# - Better 64-bit byte array hash -

webrtc - Which ICE candidate am I using and why? -

php - Zend Framework / Skeleton-Application / Composer install issue -