当前位置:首页 > 开发教程 > html教程 >

innerHTML的认识

时间:2014-06-09 23:14 来源: 作者: 收藏

相关文章:innerHTMLHTML DOM insertRow() 方法Definition and Usage定义与用法The insertRow() method is used to insert a new row in a specified position in a table.insertRow()方法可用来往表格中的指定位置上插入新行Syntax 语法tableObject.insertRo 点评:相关文章:innerHTML HTML DOM insertRow() 方法 Definition and Usage 定义与用法 The insertRow() method is used to insert a new row in a specified position in a table. insertRow()方法可用来往表格中的指定位置上插入新行 Syntax 语法 tableObject.insertRow(in
相关文章:innerHTML
HTML DOM insertRow() 方法
Definition and Usage
定义与用法
The insertRow() method is used to insert a new row in a specified position in a table.
insertRow()方法可用来往表格中的指定位置上插入新行
Syntax 语法
tableObject.insertRow(index)//索引,增添新行
--------------------------------------------------------------------------------
Example 举例
<html>
<head>
<script type="text/javascript">
function insRow()
{
document.getElementById('myTable').insertRow(0)//在文档中寻找控件
}
</script>
</head>
<body>
<table id="myTable" border="1">
<tr>
<td>Row1 cell1</td>
<td>Row1 cell2</td>
</tr>
<tr>
<td>Row2 cell1</td>
<td>Row2 cell2</td>
</tr>
</table>
<form>//表单内放置控件
<input type="button" onclick="insRow()"
value="Insert new row before the first row">//value为控件上将要显示的内容
</form>
</body>
</html>
在js方法中可以直接用成对标签的id.innerHtml对标签内容进行赋值而不需要在js方法中声明变量
innerHTML是html标签的属性,成对出现的标签大多数都有这个属性 //标签属性
是开始标签和结束标签之间的字符,不包括标签本身
比如
<p id="pp">aaaaaaaaaa<span id="ss">bbbbbbbb</span> </p>
这里的p标签和span标签嵌套在一起
那么pp.innerHTML的内容就是
aaaaaaaaaa<span id="ss">bbbbbbbb</span>
ss.innerHTML的内容就是
bbbbbbbb
=========================
类似的一个属性是outerHTML
那么pp.outerHTML的内容就是
<p id="pp">aaaaaaaaaa<span id="ss">bbbbbbbb</span> </p>
ss.outerHTML的内容就是
<span id="ss">bbbbbbbb</span>

html教程阅读排行

最新文章