zoukankan      html  css  js  c++  java
  • 对网页图片的增删改管理

    <!DOCTYPE html>
    <html>
    	<head>
    		<meta charset="UTF-8">
    		<title></title>
    		<marquee>增加修改删除图片</marquee>
    		<script type="text/javascript">
    			function addpicture(){
    				var v1 = document.createElement("img");
    				v1.src = "../../img/img/3.jpg";
    				document.getElementById("div1").insertBefore(v1,document.getElementById("p1"));				
    			}
    			function modifypicture(){
    				
    				var v3 = document.getElementById("div1");//获取父类容器
    				var arr1 =document.getElementsByTagName("img");
    				if(arr1.length>0){
    					var v4 =document.createElement("img");
    					v4.src ="../../img/img/2.jpg";
    					v3.replaceChild(v4,arr1[arr1.length-1]);
    					
    				}else{
    					alert("wrong");
    				}
    				
    			}
    			function deletepicture(){
    				var v3 = document.getElementById("div1");
    				var arr2 = document.getElementsByTagName("img");
    				if(arr2.length>0){
    					v3.removeChild(arr2[arr2.length-1]);
    				}else{
    					alert("wrong");
    				}
    			}
    		</script>
    	</head>
    	<body>
    		<div id="div1">
    			
    			<input type="button" name="btn1" id="btn1" value="add" onclick="addpicture()"/>
    			<input type="button" name="btn2" id="btn2" value="modify" onclick="modifypicture()"/>
    			<input type="button" name="btn3" id="btn3" value="delete" onclick="deletepicture()"/>
    			
    			<p id="p1"></p>
    		</div>
    	</body>
    </html>
    
  • 相关阅读:
    HDU 1050 Moving Tables(贪心)
    HDU 1009 FatMouse' Trade(贪心)
    HDU 1097 A hard puzzle(快速幂)
    HDU 1016 Prime Ring Problem(dfs)
    HDU 1010 Tempter of the Bone(dfs)
    HDU 1003 Max Sum (dp)
    mysql_01 安装
    110.平衡二叉树
    1254.统计封闭岛屿的数目
    897.递归顺序查找树
  • 原文地址:https://www.cnblogs.com/kiskistian/p/7419801.html
Copyright © 2011-2022 走看看