87,907
社区成员
发帖
与我相关
我的任务
分享
<html>
<head>
<script src="jquery-1.3.2.min.js" ></script>
<script>
$(function(){
$("div").each(function(){
if($(this).text().indexOf("1")>=0||$(this).text().indexOf("2")>=0)
alert($(this).text());
})
})
</script>
</head>
<body>
<div>
<div>
<div>1</div>
</div>
<div></div>
<div>
<div></div>
<div>
<div>2</div>
</div>
</div>
</div>
</body>
</html>
<!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 ml; charset=gb2312" />
<title>图片滚动</title>
<script src="js/jquery.js"></script>
<script>
$(document).ready(function () {
// 1节点可以直接访问到
alert($('div>div>div').html());
// 2节点只能用循环去访问的吧。
$('div>div').each(function () {
//alert('test');
if ($(this).html() == '2')
{
alert('找到2节点');
$(this).html('第二处');
}
});
});
</script>
</head>
<body>
<div>
<div>
<div>1</div>
</div>
<div></div>
<div>
<div></div>
<div>
<div>2</div>
</div>
</div>
</div>
</body>
<html>
<script>
$(document).ready(function () {
// 1节点可以直接访问到
alert($('div>div>div').html());
// 2节点只能用循环去访问的吧。
$('div>div').each(function () {
//alert('test');
if ($(this).html() == '2')
{
alert('找到2节点');
}
});
});
</script>
<!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=gb2312" />
<title>无标题文档</title>
<script type="text/javascript" src="jquery/jquery-1.4.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
alert($("div").contents().not("[nodeType=1]").val());
})
</script>
</head>
<body>
<div>
<div>
<div>1</div>
</div>
<div></div>
<div>
<div></div>
<div>
<div>2</div>
</div>
</div>
</div>
</body>
</html>
<div>
<div>
<div>1</div>
</div>
<div></div>
<div>
<div></div>
<div>
<div>2</div>
</div>
</div>
</div>