forked from nickshang/JavaScriptNote
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path14.click2.html
More file actions
40 lines (32 loc) · 991 Bytes
/
14.click2.html
File metadata and controls
40 lines (32 loc) · 991 Bytes
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
40
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
<script type="text/javascript" src="../lib/knockout/dist/knockout.js"></script>
</head>
<body>
<div>
<select data-bind="options:dropOptions,value:'9',
optionsCaption:'choose...',optionsText:'text',optionsValue:'value'" ></select>
</div>
<div>
<button type="button" data-bind="click: showSelectOption">show selected value</button>
</div>
<script type="text/javascript">
var ObjectArray = function (text, value) {
this.text = text;
this.value = value;
}
var appViewModel = function () {
var self = this;
this.dropOptions = ko.observableArray([new ObjectArray('a', 1), new ObjectArray('b', 2), new ObjectArray('c', 1)]);
this.selectedOption = ko.observable();
this.showSelectOption = function () {
alert(self.selectedOption());
}
}
ko.applyBindings(new appViewModel());
</script>
</body>
</html>