Files
StringChecker-answer/js/date.js
2026-10-15 16:52:31 +09:00

19 lines
685 B
JavaScript

$(document).ready(function() {
// ページロード時に現在時刻を取得してフォーマット
var now = new Date();
var formattedDate = now.getFullYear() + "-" +
('0' + (now.getMonth() + 1)).slice(-2) + "-" +
('0' + now.getDate()).slice(-2) + " " +
('0' + now.getHours()).slice(-2) + ":" +
('0' + now.getMinutes()).slice(-2) + ":" +
('0' + now.getSeconds()).slice(-2);
// id="date"の要素に現在時刻を挿入
$("#date").text(formattedDate);
// 投稿ボタンクリック時の処理
$("#submitBtn").click(function() {
$("#topicForm").submit(); // フォームをサブミット
});
});