為什么點擊保存沒有反應,alert里面的內容都沒彈出來
<!DOCTYPE html>
<html>
? ? <head>
? ? ? ? <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
? ? ? ? <script src="https://libs.baidu.com/jquery/1.9.0/jquery.js" type="text/javascript"></script>
? ? ? ? <title>挑戰題</title>
? ? </head>
? ? <body>
? ? ? ? <input id="username" type="text" name="" />
? ? ? ? <input id="age" type="text" name="" />
? ? ? ? <input id="save" type="button" value="保存"/>
? ? ? ? <input id="show" type="button" value="顯示"/>
? ? ? ? <ul></ul>
? ? ? ? <script type="text/javascript">
? ? ? ? ? ? $(function(){
? ? ? ? ? ? ? ? var json=[];
? ? ? ? ? ? ? ? $("#save").bind("click",function(){
? ? ? ? ? ? ? ? ? ? alert("保存");
? ? ? ? ? ? ? ? ? ? json.push({
? ? ? ? ? ? ? ? ? ? ? ??
? ? ? ? ? ? ? ? ? ? ? ? "username":$("#username").val(),
? ? ? ? ? ? ? ? ? ? ? ? "age":$("#age").val()
? ? ? ? ? ? ? ? ? ? });
? ? ? ? ? ? ? ? ? ? $("#username").val("");
? ? ? ? ? ? ? ? ? ? $("#age").val("");
? ? ? ? ? ? ? ? });
? ? ? ? ? ? ? ? $("#show").bind("click",function(){
? ? ? ? ? ? ? ? ? ? $.each(json,function(i){
? ? ? ? ? ? ? ? ? ? ? ? $("ul").append("<li>"+json[i].username+json[i].age"</li><br>")
? ? ? ? ? ? ? ? ? ? })
? ? ? ? ? ? ? ? });
? ? ? ? ? ? })
? ? ? ? </script>
? ? </body>
</html>
2018-09-17
<!DOCTYPE html>
<html>
? ? <head>
? ? ? ? <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
? ? ? ? <script src="https://libs.baidu.com/jquery/1.9.0/jquery.js" type="text/javascript"></script>
? ? ? ? <title>挑戰題</title>
? ? </head>
? ? <body>
? ? ? ? <input id="username" type="text" name="" />
? ? ? ? <input id="age" type="text" name="" />
? ? ? ? <input id="save" type="button" value="保存"/>
? ? ? ? <input id="show" type="button" value="顯示"/>
? ? ? ? <ul></ul>
? ? ? ? <script type="text/javascript">
? ? ? ? ? ? $(function(){
? ? ? ? ? ? ? ? var json=[];
? ? ? ? ? ? ? ? $("#save").bind("click",function(){
? ? ? ? ? ? ? ? ? ? alert("保存");
? ? ? ? ? ? ? ? ? ? json.push({
?? ? ? ? ? ? ? ? ? ? ? ?
? ? ? ? ? ? ? ? ? ? ? ? "username":$("#username").val(),
? ? ? ? ? ? ? ? ? ? ? ? "age":$("#age").val()
? ? ? ? ? ? ? ? ? ? });
? ? ? ? ? ? ? ? ? ? $("#username").val("");
? ? ? ? ? ? ? ? ? ? $("#age").val("");
? ? ? ? ? ? ? ? });
? ? ? ? ? ? ? ? $("#show").bind("click",function(){
? ? ? ? ? ? ? ? ? ? $.each(json,function(i){
? ? ? ? ? ? ? ? ? ? ? ? $("ul").append("<li>"+json[i].username+json[i].age+"</li><br>");
? ? ? ? ? ? ? ? ? ? })
? ? ? ? ? ? ? ? });
? ? ? ? ? ? })
? ? ? ? </script>
? ? </body>
</html>