JS阻止用户多次提交示例代码

复制代码 代码如下:

  <!doctype html>

  <html lang="en">

  <head>

  <meta charset="UTF-8">

  <title>Document</title>

  </head>

  <body>

  <input type="text" id="msg">

  <a href="#" id="result">提交</a>

  <div id="show"></div>

  <script src="jquery1.11.js"></script>

  <script>

  $(function(){

  var flag = true;

  $("#result").on('click',function(){

  if(flag){

  flag = false;

  }else{

  return;

  }

  $("#show").html('<p>'+$("#msg").val()+'</p>');

  });

  })

  </script>

  </body>

  </html>

  so easy!