zoukankan      html  css  js  c++  java
  • 为什么document.firstChild找到的不是html节点

    DOM是针对HTML4.01开发的,我们现在是XHTML1.0.

    所以要想使用核心DOM中的属性和方法,必须去掉DTD类型定义。

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
     <head>
      <title> new document </title>
      <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
      <meta name="author" content="" />
      <link rel="stylesheet" type="text/css" href="" />
      <style type="text/css"></style>
      <script type="text/javascript"></script>
     </head>
     <body>
      <table width="500" border="1">
          <tr>
                <td>姓名</td>
                <td>性别</td>
                <td>年龄</td>
          </tr>
          <tr>
                <td>奥特曼</td>
                <td></td>
                <td>26</td>
          </tr>
      </table>
      <input type="button" value="查找table节点" onclick="find_table_node()">
      <input type="button" value="修改男为女" onclick="edit_text_node()">
    
      <script type="text/javascript">
            function find_table_node(){
                //查找html节点
                var node_html=document.firstChild;
                //alert(node_html); 结果是对象
    
            }
      </script>
    
    
    
    
    
     </body>
    </html>

  • 相关阅读:
    插件集合
    postgis_LayerTransform
    react-高阶组件
    react-自定义事件
    Immutable 详解及 React 中实践
    babel-preset-env: a preset that configures Babel for you
    彻底解决Webpack打包慢的问题
    打包图片
    drag
    brush
  • 原文地址:https://www.cnblogs.com/yangzailu/p/6089115.html
Copyright © 2011-2022 走看看