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>