图片预览

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
<script src="./jquery-1.3.2.js" type="text/javascript"></script>
</head>
  <script>
 	$(document).ready(function(){
 		$("#two").click(function(){
 			var value=$("#one").val();
 			if(value==""){
 				alert("地址为空");
 			}else{
 				$(".n").append("<img id='five' src="+value+">");
 				$("#two").click(function(){
 					$(".n").empty();
 					$(".n").append("<img id='five' src="+value+">");
 				})
 			}
 		});
 		$("#three").click(function(){
 			var value=$("#one").val();
 			if(value==""){
 				alert("地址为空");
 			}else{
 				alert(value);
 			}
 		});
 		$("#four").click(function(){
 			$(".e").empty();
 			$(".e").append("<input class='one' id='one' type='file'>");
 		});
 	})
 </script>
<body>
<table>
 	<tr>
 		<td>
 			<div class="n"></div>
 			<table>
 				<tr>
 					<td>
 						<span class="o">
 						<span class="e">
 							<input type="file" class="one" id="one" value="">
 						</span>
	 						<input type="button" class="one" id="two" value="预览图片">
	 						<input type="button" class="one" id="three" value="图片地址">
	 						<input type="button" class="one" id="four" value="清除">
 						</span>
 					</td>
 				</tr>
 			</table>
 		</td>
 	</tr>
 </table>
</body>
</html>

 好像只能在IE下实现 *_*

posted @ 2018-05-07 15:35  TangYJun  阅读(189)  评论(0编辑  收藏  举报