📜  HTML | DOM 表对象

📅  最后修改于: 2021-11-09 09:16:17             🧑  作者: Mango

Table 对象用于表示 HTML

元素。它可用于创建和访问表。

句法:

  • 要访问表格元素。:
    document.getElementById("id");
  • 创建表对象:
    document.createElement("TABLE");

下面的程序说明了表对象:

示例 1:使用getElementById()方法访问

元素。



  

    Table Object in HTML
    

  

  
    

GeeksforGeeks

    

Table Object

    
       
                                                                                            
Fork PythonFork Java
Sudo PlacementFork CPP
       

Double click the "Delete Row"        button to remove the second row from the table.

                     

输出:
点击按钮前:

点击按钮后:

示例 2:使用document.createElement()方法创建

元素。



  

    Table Object in HTML
    

  

  
    

GeeksforGeeks

    

Table Object

    
       

Double click the "Create" button to create a        TABLE, a Table row and a Table cell element.

                     

输出:
点击按钮前:

点击按钮后:

支持的浏览器:

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