-
Notifications
You must be signed in to change notification settings - Fork 8
/
simple.js
39 lines (32 loc) · 1.08 KB
/
simple.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
var document = require("global/document")
var console = require("console")
var FormData = require("../index")
var elements = createElements()
document.body.appendChild(elements.root)
elements.root.addEventListener("change", function (ev) {
console.log("formdata", FormData(elements))
})
// DOM Verbosity
function createElements() {
var template = "\
<div>\
<div><label> Text field \
<input class='input' />\
</label></div>\
<div><label> Text area \
<textarea class='textarea'></textarea>\
</label></div>\
<div><label> Check box \
<input type='checkbox' class='checkbox'></input>\
</label></div>\
</div>"
var container = document.createElement("div")
container.innerHTML = template.trim()
var root = container.firstChild
return {
root: root
, input: root.getElementsByClassName("input")[0]
, textarea: root.getElementsByClassName("textarea")[0]
, checkbox: root.getElementsByClassName("checkbox")[0]
}
}