如何删除DIV内指定ID的SPAN标签及SPAN内的内容
 <div id="showfj">

<span id="AAA">
<a href="javascript:void(0)">Chrysanthemum.jpg</a>
</span>

<span id="BBB">
<a href="javascript:void(0)">Chrysanthemum.jpg</a>
</span>

<span id="CCC">
<a href="javascript:void(0)">Chrysanthemum.jpg</a>
</span>

</div>

如何删除ID为showfj的div内指定ID的span标签及里面的内容
比如我上想删除ID为showfj的div内ID为AAA的SPAN标签,该如何写

2个回答

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

function deleteMe() { var showDivNode = $("#showfj"); showDivNode.children("span").remove(); }

Insert title here




  <script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.4.2.min.js"></script>
<div id="showfj">

<span id="AAA">
<a href="javascript:void(0)">Chrysanthemum.jpg</a>
</span>

<span id="BBB">
<a href="javascript:void(0)">Chrysanthemum.jpg</a>
</span>

<span id="CCC">
<a href="javascript:void(0)">Chrysanthemum.jpg</a>
</span>

</div>

<script>
$('#showfj').html('')
</script>
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐