為什么我的代碼按保存反而跳到慕課網(wǎng)了...??
<!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>挑戰(zhàn)題</title>
? ? ? ? <style>
? ? ? ? ? ? .table p
? ? ? ? ? ? {
? ? ? ? ? ? ? ? display:inline;
? ? ? ? ? ? ? ? margin-right:10px;
? ? ? ? ? ? }
? ? ? ? ? ? #save_info,#show_info
? ? ? ? ? ? {
? ? ? ? ? ? ? ? margin-top:30px;
? ? ? ? ? ? ? ? margin-left:30px;
? ? ? ? ? ? }
? ? ? ? </style>
? ? </head>
? ? <body>
? ? ? ? <form action="#" method="get">
? ? ? ? ? <div class="table">
? ? ? ? ? ? <p>username:</p>
? ? ? ? ? ? <input id="username" type="text" placeholder="請(qǐng)輸入賬號(hào)"/>
? ? ? ? ? ? <br/>
? ? ? ? ? ? <p>password:</p>
? ? ? ? ? ? <input id="password" type="text" placeholder="請(qǐng)輸入密碼"/>
? ? ? ? ? ? <br/>
? ? ? ? ? ? <button id="save_info">Save</button>
? ? ? ? ? ? <button id="show_info">Show</button>
? ? ? ? ? </div>
? ? ? ? ? <ul id="perform"></ul>
? ? ? ? </form>
? ? <script type="text/javascript">
? ? ? ? var json = [];
? ? ? ??
? ? ? ? $("save_info").on("click",function(){
? ? ? ? ? ? json.push({
? ? ? ? ? ? ? ? username:$("username").val();
? ? ? ? ? ? ? ? password:$("password").val();
? ? ? ? ? ? })
? ? ? ? ? ? $("username").val('')
? ? ? ? ? ? $("password").val('')
? ? ? ? ? ? $("this").attr("disabled","true");
? ? ? ? ? ? alert("save success");
? ? ? ? });
? ? ? ??
? ? ? ? $("show_info").on("click",function(){
? ? ? ? ? ? $.each(json,function(index,person){
? ? ? ? ? ? ? ? $("#perform").appendChild("<li>" + "username:" +json[index].username + "password:" + json[index].password + "</li>")
? ? ? ? ? ? }
? ? ? ? })
? ? </script>
? ? </body>
</html>
2018-10-20
兄弟,你的代碼一堆語(yǔ)法錯(cuò)誤,有的id選擇器怎么連#都不加了,你把代碼代碼先丟開(kāi)發(fā)工具上排除語(yǔ)法錯(cuò)誤吧........