abstract:案例:點(diǎn)擊顯示時(shí)間<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>JavaScript</title> </hea
案例:點(diǎn)擊顯示時(shí)間
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>JavaScript</title> </head> <body> <div class="box" style="width: 500px;height: 30px;background-color: #f0c674; line-height: 30px;text-align: center" onclick="myClick(this)">點(diǎn)擊這里顯示時(shí)間</div> <script> function myClick(x) { var date = new Date(); console.log(date); x.style.backgroundColor = 'red'; x.style.color = 'white'; x.innerHTML= date; } </script> </body> </html>
點(diǎn)擊前:
點(diǎn)擊后:
小總結(jié):
熟悉js操作html元素;
熟悉js操作css樣式;
熟悉時(shí)間的獲??;
Correcting teacher:天蓬老師Correction time:2019-06-29 13:02:57
Teacher's summary:原生的Date對象內(nèi)置了許多有用的方法, 可以定制屬于你自己風(fēng)格的時(shí)間數(shù)據(jù)