为什么document找到的不是html节点_优就业

来源:互联网 发布:陀螺稳定原理 知乎 编辑:程序博客网 时间:2024/06/07 06:39

下面一起来学习一下Web前端(http://www.ujiuye.com/zt/webqianduan/)相关知识之为什么document.firstChild找到的不是html节点

为什么document找到的不是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>

为什么document找到的不是html节点_优就业

为什么document找到的不是html节点_优就业

更多Web前端知识尽在优就业IT培训:http://www.ujiuye.com/

0 0
原创粉丝点击