ハッピーメモメモ

私的備忘録

2021-10-26から1日間の記事一覧

【JavaScript】日時を表示する

例) <html> <body> <section> <p>最終アクセス日時:<span id="time"></span></p> </section> </body> </html> <script> const now = new Date(); const year = now.getFullYear(); const month = now.getMonth(); const date = now.getDate(); const hour = now.getHours(); const min = now.getMinutes(); const output = `${year}/…

【JavaScript】onsubmitイベント

onsubmitイベント 送信ボタンがクリックされた直後で、入力内容がサーバーに送信される直前に発生する。 <使用方法> 取得した要素.onsubmit = function(){ 処理内容 }; ※イベントに代入するファンクションには、ファンクション名はつけない。 <使用例> <html> <section> <form action="#" id="form"></form></section></html>…

【JavaScript】ダイアログボックス

○アラートダイアログボックス(p46) window.alert('ここに書いた文字や数式がでる'); 使用例)データの中身を確かめるのに、console.log()みたいに使える。 alert('click'); ○確認ダイアログボックス(p58) window.confirm('メッセージ'); confirmメソッド…

【JavaScript】要素をさわる

○要素の取得-1(id) document.getElementById('id名') 例)html <p id="choice">ここに日時を表示します</p> JavaScript console.log(document.getElementById('choice')); ○要素の取得-2(cssセレクタ) document.querySelector('CSSセレクタ') 例)HTMLのボタンをクリックし…