dom

111111

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>form.html</title>

<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="this is my page">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>
<body>
<div );
//
// //3 插入
// divElement.appendChild(h1Element);

//方法二
document.getElementById("city").innerHTML = "<h1>今天</h1>";

</script>


</html>

2222222222222222222222222222222222222222222222222222222222222

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>insertBefore.html</title>
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="this is my page">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
</head>
<body>
<ul );

//2 获取父元素
var parentElement = bjElement.parentNode;

//3 删除
parentElement.removeChild(bjElement);

</script>
</html>

33333333333333333333333333333333333333333333333333333333

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>insertBefore.html</title>
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="this is my page">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<!--<link rel="stylesheet" type="text/css" href="./styles.css">-->
</head>
<body>
<ul>
<li );

//3 获取重庆节点的父节点
var parentElement = cqElement.parentNode;

//4 插入
parentElement.insertBefore(liElement,cqElement);

</script>
</html>

4444444444444444444444444444444444444444444444444444444444444444

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>form.html</title>

<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="this is my page">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
</head>

<body>
<select name="edu" >幼儿园^^^^^</option>
</select>

</body>
<script language="JavaScript">
//增加节点<option value="大专">大专^^^^^</option>
//1 创建<option value="大专">大专^^^^^</option>
//1 <option></option>
var optionElement = document.createElement("option"); //创建元素节点createElement(),传入的是标签名

//2 设置属性<option value="大专"></option>
optionElement.setAttribute("value","大专");

//3 创建一个文本节点
var textElement = document.createTextNode("大专^^^^^"); //创建文本节点createTextNode(),传入的是文本内容

//4 文本节点插入到option标签,<option value="大专">大专^^^^^</option>
optionElement.appendChild(textElement); //插入子元素,appendChild(传入子元素内容)

//2 获取select标签
var eduElement = document.getElementById("edu");

//3 插入
eduElement.appendChild(optionElement);


</script>
</html>