当前位置: 代码迷 >> HTML/CSS >> innerHtml小例证
  详细解决方案

innerHtml小例证

热度:92   发布时间:2012-09-19 13:43:54.0
innerHtml小例子
<html>
<head>
<script type="text/javascript">
function getInnerHTML()
  {
  //alert(document.getElementById("id1").innerHTML);
  if(document.getElementById("id1").innerHTML != ""){
	alert("true")
  }else{
	alert("false");
  }
  }
</script>
</head>
<body>

<table border="1">
<tr id="tr1">
<th>Firstname</th>
<th>Lastname</th>
</tr>
<tr id="tr2">
<td id="id1">Peter</td>
<td>Griffin</td>
</tr>
</table>
<br />
<input type="button" onclick="getInnerHTML()" 
value="Alert innerHTML of table row" />

</body>
</html>
  相关解决方案