-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathselect.ts
39 lines (33 loc) · 1.01 KB
/
select.ts
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
import { Div } from "./div";
class Select extends Div {
items: string;
constructor(props:any) {
super(props);
let items = [];
if (props) {
if (props.items) {
items = props.items;
this.items = "";
items.forEach((item:any) => {
this.items += `\t<option value="${item}">${item}</option>`
});
this.htmlString = `<select>\n${this.items}</select>`;
//console.log(this.htmlString);
this.createNode();
}
if (props.parent) {
this.appendTo(props.parent);
}
}
}
getChecked() {
return this.node.options[this.node.selectedIndex].value;
}
setChecked(choice:any) {
this.node.options[this.node.selectedIndex].value = choice;
}
click(clickFN:any) {
this.node.addEventListener("click", clickFN);
}
}
export { Select };