久久r热视频,国产午夜精品一区二区三区视频,亚洲精品自拍偷拍,欧美日韩精品二区

您的位置:首頁技術(shù)文章
文章詳情頁

JavaScript實(shí)現(xiàn)簡(jiǎn)單日期特效

瀏覽:36日期:2023-06-05 17:10:35

JavaScript之日期特效的具體代碼,供大家參考,具體內(nèi)容如下

直接上代碼:

<!DOCTYPE html><html lang='en'><head> <meta charset='UTF-8'> <title>Title</title> <style type='text/css'>*{ padding: 0; margin: 0;}#date{ width: 450px; height: 300px; background-color: darkorange; border-radius: 10px; margin: 100px auto;}#nowDate{ width: 450px; height: 60px; line-height: 60px; text-align: center; color: #fff; font-size: 26px;}#day{ width: 200px; height: 200px; line-height: 200px; background-color: orchid; margin: 0 auto; text-align: center;} </style></head><body> <div id='date'><p id='nowDate'></p><p id='day'></p> </div> <script type='text/javascript'>// 獲取標(biāo)簽var nowDate = document.getElementById('nowDate');var day = document.getElementById('day');// 用定時(shí)器 更新時(shí)間的變化setInterval(nowNumTime,1000);nowNumTime();function nowNumTime(){ var now = new Date(); var hour = now.getHours(); var minute = now.getMinutes(); var second = now.getSeconds(); var temp = ’’ + (hour>12 ? hour-12:hour); var year = now.getFullYear(); var month = now.getMonth(); var d = now.getDate(); var week = now.getDay(); console.log(week); //索引 var weeks = ['星期天','星期一','星期二','星期三','星期四','星期五','星期六']; // console.log(temp); if (hour ===0){temp = ’12’; } temp = temp + (minute <10 ? ’:0’:':'+minute); temp = temp + (second <10 ? ’:0’:':'+second); temp = temp + (hour>=12 ? ’ P.M.’:’ A.M.’); temp = `${year}年${month}月$dv1hrpp7z日 ${temp}${weeks[week]}`; // console.log(temp); nowDate.innerHTML = temp;} </script></body></html>

實(shí)現(xiàn)效果圖:

JavaScript實(shí)現(xiàn)簡(jiǎn)單日期特效

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持好吧啦網(wǎng)。

標(biāo)簽: JavaScript
相關(guān)文章:
主站蜘蛛池模板: 班玛县| 城固县| 大英县| 曲阜市| 澜沧| 桃园县| 玉屏| 离岛区| 军事| 富宁县| 昌乐县| 伊宁市| 太湖县| 白山市| 吴旗县| 海盐县| 岳普湖县| 新余市| 朔州市| 曲靖市| 平陆县| 湄潭县| 巴林右旗| 青川县| 思南县| 丹凤县| 英超| 探索| 香格里拉县| 宾阳县| 兴文县| 会东县| 达日县| 嘉鱼县| 紫金县| 福建省| 周宁县| 敖汉旗| 鹤峰县| 准格尔旗| 罗定市|