📜  HTML | DOM 节对象

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

HTML DOM 中的 Section 对象用于表示 HTML

元素。可以使用 getElementById() 方法访问 section 元素。

句法:

document.getElementById("id")

其中 id 分配给

标签。
示例 1:

html


    
        
            HTML DOM section Object
        
    
     
    
 
        

            GeeksForGeeks         

                  

DOM section Object

                                     

          
            A computer science portal for geeks.         
                       


html


    
        
            HTML DOM section Object
        
    
     
    
        

            GeeksForGeeks         

                  

DOM section Object

          
                  


输出:
点击按钮前:

部分

点击按钮后:

部分

示例 2:可以使用 document.createElement 方法创建 Section 对象。

html



    
        
            HTML DOM section Object
        
    
     
    
        

            GeeksForGeeks         

                  

DOM section Object

          
                                      

输出:
点击按钮前:

部分

点击按钮后:

部分

支持的浏览器:

  • 谷歌浏览器
  • 火狐浏览器
  • 边缘
  • 苹果浏览器
  • 歌剧