1 方法 javaScript : 문서 .getElementById ( "id"). innerHtml;
(1))
复制代码代码如下 :
<! 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">
<헤드>
<meta http-equiv = "content-type"content = "text /html; charset = utf-8" />
<title> t html </title>
<script type = "text/javaScript">
함수 getstr ()
{
var str = document.getElementById ( "div_child"). innerHtml;
경고 (str);
}
</스크립트>
</head>
<body>
<div id = "div_child">
<테이블>
<tr>
<th> </th>
<th> </th>
<th> </th>
<th> </th>
<th> </th>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
</테이블>
<입력 유형 = "버튼"id = "btn"onclick = "getstr ()"value = "获取字符串"/>
</div>
</body>
</html>
(2)), 弹出信息
2 中的方法 jQuery 、 : $ ( "#id"). html ()
(1))
复制代码代码如下 :
<! 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">
<헤드>
<meta http-equiv = "content-type"content = "text /html; charset = utf-8" />
<title> jQuery j </title>
<script type = "text/javaScript"src = "jQuery-2.1.0.js"> </script>
<script type = "text/javaScript">
$ (function () {
$ ( "#btn"). 클릭 (function () {
var str = $ ( "#div_child"). html ();
경고 (str);
});
});
</스크립트>
</head>
<body>
<div id = "div_child">
<테이블>
<tr>
<th> </th>
<th> </th>
<th> </th>
<th> </th>
<th> </th>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
</테이블>
<입력 유형 = "버튼"id = "btn"value = "获取值"/>
</div>
</body>
</html>
(2))