87,907
社区成员
发帖
与我相关
我的任务
分享
<div id="parentID">
<div id="childOne">one</div>
<div id="childTwo">two</div>
<div id="childThree">three</div>
<div id="childFour">four</div>
<input type="button" id="btn" onclick="shows(this);"/>
</div>
<script>
function shows(obj)
{
alert($(obj).parent().children().eq(2).text());
}
</script>
alert($(obj).parent().filter("#childThree"));
alert($(obj).parent().children("#childThree"));
alert($(obj).parent().find("#childThree"));
<div id="parentID">
<div id="childOne">one</div>
<div id="childTwo">two</div>
<div id="childThree">three</div>
<div id="childFour">four</div>
<input type="button" id="btn" />
</div>
$(function(){
$("#btn").click(function(){
var text = $(this).parent().children("#childThree").text();
alert(text);
var text1 = $(this).parent().children(":eq(2)").text();
alert(text1)
});
});