html清空按钮代码,HTML DOM console.clear()用法及代码示例

HTML中的console.clear()方法用于清除控制台,并在每次执行时在控制台上写一些消息“Console was cleared”。此方法不需要任何参数。

用法:

console.clear()

以下示例程序旨在说明HTML中的console.clear()方法:

例:

DOM console.clear() Method in HTML

h1 {

color:green;

}

h2 {

font-family:Impact;

}

body {

text-align:center;

}

GeeksforGeeks

DOM console.clear() Method

To view the message in the console press the F12

key on your keyboard.

To clear the console, double click

the button below:

Clear Console

console.log("GeeksforGeeks is a portal for geeks!");

function clear_console() {

console.clear();

}

输出:

532ac5625c5d64266995f0af6426773a.png

按下F12键时的控制台视图:

7331a4cefe5d18b54106ca9e147a4e2c.png

双击清除按钮后,查看控制台视图:

a22998d3edcb565424f8d32e23817a44.png

支持的浏览器:console.clear()方法支持的浏览器如下:

谷歌浏览器

IE浏览器

火狐浏览器

Opera

苹果浏览器

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值