欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

jquery----删除指定id的div下的img

程序员文章站 2022-03-10 11:33:13
...

index.jsp代码:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<title>jquery</title>

		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<script type="text/javascript" src="javascript/jquery-1.4.js">
</script>
		<script type="text/javascript" src="javascript/elements.js">
</script>
		<script type="text/javascript" src="javascript/jqia2.support.js">
</script>
		<script type="text/javascript">
  function one(){
	$('#dimg img').remove();
}
</script>
	</head>
	<body>
		<div id="dimg">
			<img src="images/image.1.jpg" id="hibiscus" alt="Hibiscus" />
			<img src="images/image.2.jpg" id="littleBear"
				title="A dog named Little Bear" />
			<img src="images/image.3.jpg" id="verbena" alt="Verbena" />
			<img src="images/image.4.jpg" id="cozmo" title="A puppy named Cozmo" />
			<img src="images/image.5.jpg" id="tigerLily" alt="Tiger Lily" />
			<img src="images/image.6.jpg" id="coffeePot" />
			<img src="images/image.6.jpg" id="coffeePot" />
		</div>
		<div>
		  <input type="button" onclick="one()" value="button">
		</div>
	</body>
</html>



运行结果:

jquery----删除指定id的div下的img
            
    
    博客分类: jquery  

点击button按钮之后,效果如下:

jquery----删除指定id的div下的img
            
    
    博客分类: jquery  

  • jquery----删除指定id的div下的img
            
    
    博客分类: jquery  
  • 大小: 18.8 KB
  • jquery----删除指定id的div下的img
            
    
    博客分类: jquery  
  • 大小: 6.5 KB