Created
January 16, 2016 02:52
-
-
Save chikoski/4cdca3c52f8f6e502a55 to your computer and use it in GitHub Desktop.
appendChild の練習
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var list = document.querySelector("#list"); | |
| var titleElement = document.querySelector("#title"); | |
| var registerButton = document.querySelector("#register"); | |
| function registerItem(title, dueDate){ | |
| var item = document.createElement("li"); | |
| var text = title + "(" + dueDate + ")"; | |
| item.textContent = text; | |
| list.appendChild(item); | |
| } | |
| function register(){ | |
| var title = titleElement.value; | |
| if(title != null && title.length > 0){ | |
| registerItem(title, "いつか"); | |
| } | |
| } | |
| registerButton.addEventListener("click", register); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!doctype html> | |
| <html> | |
| <head> | |
| <title>課題のリスト</title> | |
| <meta charset="utf-8"> | |
| </head> | |
| <body> | |
| <input type="text" id="title"> | |
| <button id="register">登録</button> | |
| <ul id="list"> | |
| </ul> | |
| <script src="app.js"></script> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment