jQuery,元素获取问题,谢谢。
问题描述:
<div>
<input type="checkbox" id="che3" name="che2" mtype="che:10:10" value="a4"/>a4
<input type="checkbox" mtype="che:10:10" id="che4" name="che2" value="a6"/>a6
<span></span>
</div>
怎么获取id=che3的相临span,想通过append插入数据。
答
<div>
<input type="checkbox" id="che3" name="che2" mtype="che:10:10" value="a4" />a4
<input type="checkbox" mtype="che:10:10" id="che4" name="che2" value="a6" />a6
<span></span>
</div>
<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.4.1.min.js"></script>
<script>
$('#che3').siblings('span').filter(':last').html('abc')
</script>
答
$("#che3").siblings("span")
答
var span=$("#che3")~$("span"):first
答
在SPAN 上也加上ID就好了
直接获取SPAN
答
$("#che3 span").innerHTML()