js中元素更新value頁面體現不出來的緣由

<!DOCTYPE html>
<html lang="en">
 <head> 
  <meta charset="UTF-8" /> 
  <meta name="viewport" content="width=device-width,initial-scale=1 user-scalable=0" /> 
  <title>js中設置值頁面體現不出來的緣由</title> 
  <script src="./qrcodejs/jquery.min.js" type="text/javascript" charset="utf-8"></script> 
	<script>	
		$(document).ready(function(){
			//
			$("#btn").click(function(){
				alert('You click Me now!');
			});
			$("#container").html('<button type="button" id="btn">Click Me!</button>');
			//
			$("#yourname").val('liuchao');
			$("#content").html('<input type="text" id="yourname" name="yourname" size="30" maxlength="20" value="輸入框的長度爲30,容許最大字符數爲20">');
		});
	</script>
  <style>
	*{
		margin:0px;
		padding:0px;
	}
	</style> 
 </head> 
 <body>
<div id="container"> 
  <button type="button" id="btn">Click Me!</button>
</div>
<div id="content">
	<input type="text" id="yourname" name="yourname" size="30" maxlength="20" value="輸入框的長度爲30,容許最大字符數爲20">
</div>
 </body>
</html>
相關文章
相關標籤/搜索