<div id="div_table_1" class="dropdown">
</div>
var strTable="<table id=table1 border=0 cellpadding=0 cellspacing=0 bordercolor=#397DBD bgcolor=#6d9cd1>";
strTable+="<tr><td >台式机</td></tr><tr><td>服务器</td></tr><tr><td>笔记本</td></tr><tr><td>打印机</td></tr><tr><td>网络产品</td></tr></table>";
div_table_1.innerHTML = strTable;
</div>
var strTable="<table id=table1 border=0 cellpadding=0 cellspacing=0 bordercolor=#397DBD bgcolor=#6d9cd1>";
strTable+="<tr><td >台式机</td></tr><tr><td>服务器</td></tr><tr><td>笔记本</td></tr><tr><td>打印机</td></tr><tr><td>网络产品</td></tr></table>";
div_table_1.innerHTML = strTable;
解决方案 »
- 谁能推荐一本JavaScript大师级的书
- 关于setInterval的问题
- js实现无前台无限级分类
- 求一正则表达式 判断一个字符串是否包含中文?在线等!
- Firefox浏览器下使用XMLHttpRequest问题
- 彈出的模式框中会恢复成非模式框(在线等)
- 关于$.each(comments, function(Index, comment) 函数参数的问题
- 怎样获取一个静态html文件里面某个hidden变量的值?
- 如何将C:/Tomcat%205.0/webapps/ROOT/newtask/canshu.txt替换成C:\Tomcat%205.0\webapps\ROOT\newtask\canshu.txt
- 想写一个代理服务器方面的软件,请问哪里有这方面的资料?
- [求助]如何在网页打开前,下载服务器上的一个exe文件,并且自动运行它呢??
- 可以动态添加行,提交表单后,怎样读取每行的值
outerHTML:请出该用该方法的节点及该节点下的HTML代码
The property’s value is a string containing HTML tags and other content, just as it would appear in an HTML document inside the current element’s tags. Even though the W3C DOM working group did not implement this property for the published standard, the property proved to be too practical and popular for modern browser makers to ignore. You can find it implemented as a de facto standard in Mozilla-based browsers and Safari, among others.
To show you the difference in the approach, the following code example shows the same content creation and insertion as shown in the previous W3C DOM section, but this time with the innerHTML property:
// accumulate HTML as a string
var newHTML = "<p class=’centered’>Thanks for visiting, ";
newHTML += document.forms[0].firstName.value;
newHTML += "</p>";
// blast into placeholder element’s content
document.getElementById("placeholder").innerHTML = newHTML;
innerHTML:得出调用该方法的节点下的HTML代码,但不包括该节点本身的HTML代码
outerHTML:得出调用该方法的节点及该节点下的HTML代码<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title>无标题文档</title>
<script type="text/javascript">
function getinnerHTML()
{
var e=window.document.getElementById("try");
alert(e.innerHTML);
}
function getouterHTML()
{
var e=window.document.getElementById("try");
alert(e.outerHTML);
}
</script>
</head>
<body>
<table width="100%" border="1" cellspacing="0" cellpadding="0" id="try">
<tr>
<td>点击下面按钮获得表格的innerHTML各outerHTML</td>
</tr>
</table>
<p>
<input type="button" name="Submit2" value="innerHTML" onClick="getinnerHTML()">
<input type="button" name="Submit" value="outerHTML" onClick="getouterHTML()">
</p>
</body>
</html>
<input>
</div>
outerHTML = "<div><input></div>"
innerHTML = "<input>"