欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

父節(jié)點(diǎn)獲取子節(jié)點(diǎn)的字符串示例代碼

 更新時(shí)間:2014年02月26日 16:32:07   作者:  
這篇文章主要介紹了父節(jié)點(diǎn)獲取子節(jié)點(diǎn)的字符串的方法,需要的朋友可以參考下
1、JavaScript方法:document.getElementById("id").innerHTML;

(1)實(shí)例說(shuō)明
復(fù)制代碼 代碼如下:

<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>獲取HTML中的子項(xiàng)</title>
<script type="text/javascript">
function getStr()
{
var str = document.getElementById("div_child").innerHTML;
alert(str);
}
</script>
</head>

<body>
<div id="div_child">
<table>
<tr>
<th></th>
<th></th>
<th></th>
<th></th>
<th></th>
</tr>
<tr>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
</tr>
</table>
<input type="button" id="btn" onclick="getStr()" value="獲取字符串"/>
</div>
</body>
</html>

(2)點(diǎn)擊按鈕后,彈出信息
 
2、jQuery中的方法:$("#id").html()

(1)實(shí)例說(shuō)明
復(fù)制代碼 代碼如下:

<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>jQuery中父節(jié)點(diǎn)獲取子節(jié)點(diǎn)字符串</title>
<script type="text/javascript" src="jquery-2.1.0.js"></script>
<script type="text/javascript">
$(function(){
$("#btn").click(function(){
var str = $("#div_child").html();
alert(str);
});
});
</script>
</head>

<body>
<div id="div_child">
<table>
<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>
</table>
<input type="button" id="btn" value="獲取值"/>
</div>
</body>
</html>

(2)運(yùn)行結(jié)果

相關(guān)文章

最新評(píng)論