d Class
Global Object for DOM tools. javascript has DOM functions to change the HTML elements dynamically. However, the commands name is long and not useful. This object provides short names and useful functions.
Item Index
Methods
addEv
-
hash
Add an event listener to A DOM Element.
Parameters:
-
hashObjectt: target DOM, m: event messeage without "on", f:function.
app
-
par -
t -
opt
append new DOM Element as the last child of par Element .
Parameters:
-
parDOMElementParent DOM Element.
-
tStringtarget element DOM Element.
-
optObjectattribute and childs. See d.mod .
Returns:
cat
-
a -
b
concat two array. a array added all of b array at the end of a array.
Parameters:
-
aArrayArray to modified
-
bArrayArray which has childs to add
Returns:
get
-
id
Get a DOM element named id.
Parameters:
-
idStringId of the element.
go
-
e -
pos
Move DOM Element to there. The DOM must has style.position "absolute" or "relative".
Parameters:
-
eDOMElementA DOM Element.
-
posArrayNumberArray of [left,top].
json2html
-
e -
json
Create DOM Elements under the e element. This is an enhansment of d.app. order of json become the order of child. The children of Array must be 3 type.
- String: the string become text node. Note that you cannot add HTML tags here.
- Array: Become an element. [0] becomes tag name (must be String.), [1] becomes child nodes. (it must be Array as the parameter __json__.)
- Object: 0: as the same with Array's 0. 1: as the same with Array's 1. the others: become the attribute of the element. See d.mod for detail.
Parameters:
-
eDOMElementA DOM Element.
-
jsonArrayrepresentation of HTML.
mod
-
e -
opt
append or modify childs of e object by opt object. If e and opt has a child of the same name, it is overwrite by opt's. This is well used for attribute setting of DOM Element and setting method functions in a new object. Thus, this function does not copy recursively. There is one exception. if opt has the child "style" and pass both of the "style" child to d.style method.
Parameters:
-
eDOMElementParent DOM Element.
-
optObjectobject of modifing childs.
Returns:
prep
-
par -
t -
opt
insert new DOM Element as a first child of par Element.
Parameters:
-
parDOMElementParent DOM Element.
-
tStringtarget element DOM Element.
-
optObjectattribute and childs. See d.mod .
Returns:
Example:
<div id="debug"></div>
<script>
d.prep(d.get("debug"),"p",{innerHTML:"123"});
</script>
removeAll
-
e
remove all the children of the DOM element.
Parameters:
-
eDOMElementA DOM Element.
rmEv
-
hash
Remove an event listener to A DOM Element.
Parameters:
-
hashObjectt: target DOM, m: event messeage without "on", f:function.
style
-
e -
sty
set style of DOM element.
Parameters:
-
eObjectstyle arribute of A DOM Element.
-
styObjectobject of strings for styling.
Properties
d
DOM Element
public
abbreviation of document
Default: document
ie
Integer
public
A Flag for Old Internet Explores.
- 0
- mozilla.org gecco engine (fireforx, seamonkey or some)
- 1
- InternetExplore older than Ver. 9
- 2
- InternetExplore after ver. 9 or opera
root
String
public
root path of script codes.
