用法:
对象.siblings('元素');
例子:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>New Web Project</title>
<script type="text/javascript" src="jquery-core/jquery-1.8.0.js"></script>
<script type="text/javascript">
$(function(){
//设置class为d1的所有同辈div的html为:我是class为d1的同辈div
$('.d1').siblings('div').html('我是class为d1的同辈div');
});
</script>
</head>
<body>
<div class="d1">
</div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
</body>
</html>
对象.siblings('元素');
例子:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>New Web Project</title>
<script type="text/javascript" src="jquery-core/jquery-1.8.0.js"></script>
<script type="text/javascript">
$(function(){
//设置class为d1的所有同辈div的html为:我是class为d1的同辈div
$('.d1').siblings('div').html('我是class为d1的同辈div');
});
</script>
</head>
<body>
<div class="d1">
</div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
</body>
</html>