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:
-
hash
Objectt: 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:
-
par
DOMElementParent DOM Element.
-
t
Stringtarget element DOM Element.
-
opt
Objectattribute 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:
-
a
ArrayArray to modified
-
b
ArrayArray which has childs to add
Returns:
get
-
id
Get a DOM element named id.
Parameters:
-
id
StringId of the element.
go
-
e
-
pos
Move DOM Element to there. The DOM must has style.position "absolute" or "relative".
Parameters:
-
e
DOMElementA DOM Element.
-
pos
ArrayNumberArray 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:
-
e
DOMElementA DOM Element.
-
json
Arrayrepresentation 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:
-
e
DOMElementParent DOM Element.
-
opt
Objectobject of modifing childs.
Returns:
prep
-
par
-
t
-
opt
insert new DOM Element as a first child of par Element.
Parameters:
-
par
DOMElementParent DOM Element.
-
t
Stringtarget element DOM Element.
-
opt
Objectattribute 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:
-
e
DOMElementA DOM Element.
rmEv
-
hash
Remove an event listener to A DOM Element.
Parameters:
-
hash
Objectt: target DOM, m: event messeage without "on", f:function.
style
-
e
-
sty
set style of DOM element.
Parameters:
-
e
Objectstyle arribute of A DOM Element.
-
sty
Objectobject 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.