Skip to content

Instantly share code, notes, and snippets.

@inoh
Last active December 19, 2015 15:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save inoh/5975941 to your computer and use it in GitHub Desktop.
Save inoh/5975941 to your computer and use it in GitHub Desktop.
Dart
import 'dart:html';
InputElement testInput;
UListElement testList;
ButtonElement testDelete;
void main() {
testInput = query("#test-input");
testList = query("#test-list");
testDelete = query("#delete-all");
testInput.onChange.listen(addList);
testDelete.onClick.listen(deleteAll);
}
void addList(Event e) {
var newList = new LIElement();
newList.text = testInput.value;
testInput.value = "";
testList.children.add(newList);
}
void deleteAll(Event e) {
testList.children.clear();
}
@inoh
Copy link
Author

inoh commented Jul 11, 2013

HTML

<h1>TestPage</h1>

<div>
  <input id="test-input" type="text"></input>
</div>    

<div>
  <ul id="test-list"></ul>
</div>

<div>
  <button id="delete-all" type="button">全件削除</input>
</div>

<script type="application/dart" src="test.dart"></script>
<script src="packages/browser/dart.js"></script>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment