返回 点击显示时间... 登陆

点击显示时间

阿涛 2019-06-29 11:04:03 297

案例:点击显示时间

<!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)">点击这里显示时间</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>

点击前:

QQ截图20190629105942.png

点击后:

QQ截图20190629105952.png

小总结:

熟悉js操作html元素;

熟悉js操作css样式;

熟悉时间的获取;

最新手记推荐

• 用composer安装thinkphp框架的步骤 • 省市区接口说明 • 用thinkphp,后台新增栏目 • 管理员添加编辑删除 • 管理员添加编辑删除

全部回复(0)我要回复

暂无评论~
  • 取消 回复 发送
  • PHP中文网