The Official Blog of Patcoola

Im just a dude watching over my parents,
and trying to make cartoons and video games from home.

DOM API [JavaScript]

, By Patcoola

Script Title: DOM API
Script Language: JavaScript
Date Created: 2020-06-04

Purpose: Provides short-cuts for the DOM selector functions, essential features, and legacy support.

Description: DOM API is a short-cuts application programming interface (API) for the Document Object Model (DOM) programming interface in HTML. DOM is easy to remember and save time by providing a shorten language. DOM also provides essential commonly used functions, and legacy support across browsers.

Advertisement


Example:

document.getElementById(“myElementID”);

// DOM API (alias)

dom.getID(“myElementID”);

Methods:

dom.getID( string )

Alias for getElementsById, returns an element

dom.getTagged( string )

Alias for getElementsByTagName, returns an array of elements

dom.getTaggedFirst( string )

Returns the first element from getElementsByTagName

dom.getTaggedLast( string )

Returns the last element from getElementsByTagName

dom.getForByID( string )

Returns the element from the ID assigned to a For attribute

dom.query( string )

Alias for querySelector, returns an element
Basic legacy support ( [attr], [attr=”name”], .classNS, Element.classNS, Element )

dom.queryAll( string )

Alias for querySelectorAll, returns an array of elements
Basic legacy support ( [attr], [attr=”name”], .classNS, Element.classNS, Element )

dom.addEvent( event, function )

Set an event for the document/window
( Do not include ‘on’ )

dom.addLoadEvent( function )

Set a function to execute when the document/window has loaded

dom.delEvent( event, function )

Removes an event for the document/window

dom.fireEvent( event )

Activates an event for the document/window

dom.empty( value )

Determines if the value is empty, returns a boolean

dom.isSet( value )

Determines if the value is set, returns a boolean

dom.type( value )

Returns the data or object type, returns a string
Examples: array, object, HTMLElement

dom.trim( string )

Removes unwanted spaces from start and end of a string, returns a string

dom.iFrame( elm ).format()

A function to create the HTML document in a created iFrame

dom.iFrame( elm ).isAccessible()

Determines if iFrame is accessible, returns a boolean

dom.iFrame( elm ).getID( string )

Alias for getElementsById within an iFrame, returns an element

dom.iFrame( elm ).getTagged( string )

Alias for getElementsByTagName within an iFrame, returns an array of elements

dom.iFrame( elm ).getTaggedFirst( string )

Returns the first element from getElementsByTagName within an iFrame

dom.iFrame( elm ).getTaggedLast( string )

Returns the last element from getElementsByTagName within an iFrame

dom.iFrame( elm ).getForByID( string )

Returns the element from the ID assigned to a For attribute within an iFrame

dom.iFrame( elm ).getDoc()

Returns the document/window element of the iFrame

dom.iFrame( elm ).query( string )

Alias for querySelector, returns an element
Basic legacy support ( [attr], [attr=”name”], .classNS, Element.classNS, Element )

dom.iFrame( elm ).queryAll( string )

Alias for querySelectorAll, returns an array of elements
Basic legacy support ( [attr], [attr=”name”], .classNS, Element.classNS, Element )

dom.iFrame( elm ).addEvent( event, function )

Set an event for the iFrame document/window
( Do not include ‘on’ )

dom.iFrame( elm ).delEvent ( event, function )

Removes an event for the iFrame document/window

dom.iFrame( elm ).fireEvent ( event )

Activates an event for the iFrame document/window

dom.elm( elm | ID ).addEvent( event, function )

Set an event for an element
( Do not include ‘on’ )

dom.elm( elm | ID ).delEvent ( event, function )

Removes an event for an element

dom.elm( elm | ID ).fireEvent ( event )

Activates an event for an element

dom.elm( elm | ID ).getParent()

Returns the parent element

dom.elm( elm | ID ).isValue()

Determines if the element has the value property, returns a boolean

dom.elm( elm | ID ).setValues( array, value )

Sets the value to the given array options: value, text, index, attribute

dom.elm( elm | ID ).getValueFrom( string )

Returns the value from the option: value, text, index, attribute

dom.elm( elm | ID ).insert( elm, position )

Inserts a created element or moves an element to a position
(0 ‘first’ child, 1 ‘last’ child, 2 ‘above’ element, 3 ‘below’ element, 4 ‘body’)

dom.elm( elm | ID ).remove()

Removes an element

dom.elm( elm | ID ).hasClassNS( string )

Determines if an element has a class name, returns a boolean

dom.elm( elm | ID ).addClassNS( string )

Appends a class name to an element

dom.elm( elm | ID ).delClassNS( string )

Removes a class name from an element

dom.elm( elm | ID ).getCurrentStyle( string )

Returns the value of computed style from an elements

dom.elm( elm | ID ).getID( string )

Alias for getElementsById within an element, returns an element

dom.elm( elm | ID ).getTagged( string )

Alias for getElementsByTagName within an element, returns an array of elements

dom.elm( elm | ID ).getTaggedFirst( string )

Returns the first element from getElementsByTagName within an element

dom.elm( elm | ID ).getTaggedLast( string )

Returns the last element from getElementsByTagName within an element

dom.elm( elm | ID ).getFor( string )

Returns the element from the ID assigned to a For attribute

dom.elm( elm | ID ).query( string )

Alias for querySelector, returns an element from within an element
Basic legacy support ( [attr], [attr=”name”], .classNS, Element.classNS, Element )

dom.elm( elm | ID ).queryAll( string );

Alias for querySelectorAll, returns an array of elements from within an element
Basic legacy support ( [attr], [attr=”name”], .classNS, Element.classNS, Element )

Selector Chains and Nested Selectors

document.getElementById(“myElementID”).querySelector (“[myAttribute=’first’]”);

// alias first selector

dom.getID(“myElementID”).querySelector(“[myAttribute=’first’]”);

// alias

dom.elm(“myElementID”).query(“[myAttribute=’first’]”);

 

Advertisement


 

Post Meta

Share Post

 

Comments: Write Comment

Be the first to write a comment.


Leave a Comment


All comments are reviewed before publishing. Comments must be related to the page topic, must not be spam, and must comply with the criminal code of Canada.

 

Matched Content