Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
Article information
RevisionsShow article in Markdown
Report article
Help us understand the problem. What is going on with this article?

This post is Private. Only a writer or those who know its URL can access this post.

@kurosawa_kuro

基礎学習 JavaScript編 実践 TodoApp

<!DOCTYPE html>
<html lang="jp">

<head>
    <meta charset="UTF-8">
    <title>JS App</title>
</head>

<body>
<input type="text" id="todo-title" placeholder="Todoを入力して下さい">
<button id="btn-todo">
    追加
</button>

<p id="todo-container"></p>

<script>
    const inputTodoTitle = document.getElementById("todo-title");
    const buttonTodo = document.getElementById("btn-todo");
    const containerTodo = document.getElementById("todo-container");

    // 追加ボタンをクリックしたら実行されるイベントリスナーを設定
    buttonTodo.addEventListener('click', e = > {

    console.log("btnTodo.addEventListenerが起動しました");

    // submitイベントのデフォルト動作(ページリロードなど)を実行しないよう設定
    e.preventDefault();

    // inputタグのオブジェクトが取得されているかを確認
    console.log("inputTodoTitle : " + inputTodoTitle);

    // inputタグに入力された値を取得
    const addeTodo = inputTodoTitle.value;
    console.log("入力されたのは : " + addeTodo);

    // 入力された値をcontainerTodoのinnerTextプロパティに代入しなさい。
    containerTodo.insertAdjacentHTML('beforeend', addeTodo);
    })
</script>
</body>
</html>
Article information
RevisionsShow article in Markdown
Report article
Help us understand the problem. What is going on with this article?
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
kurosawa_kuro
三十半ばで最新技術を学びたくて札幌からかなり遅めの上京、その後約一年半後転職して、 ブロックチェーンとデータサイエンスの研究開発始める事になりました。 https://github.com/kurosawa-kuro
it-geinin
技術を使って日々面白いことに挑戦し、Qiitaに投稿します。技術を楽しむ会です。

Comments

No comments
Sign up for free and join this conversation.
Sign Up
If you already have a Qiita account Login
Article information
RevisionsShow article in Markdown
Report article
Help us understand the problem. What is going on with this article?