📜  HTML | DOM console.clear() 方法

📅  最后修改于: 2021-11-07 08:52:37             🧑  作者: Mango

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

句法:

console.clear()

下面的程序说明了 HTML 中的 console.clear() 方法:

例子:



     
        DOM console.clear() Method in HTML 
         
    
    
        

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:         


                                           

输出:

按 F12 键时的控制台视图:

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

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

  • 谷歌浏览器
  • IE浏览器
  • 火狐
  • 歌剧
  • 苹果浏览器