Py学习  »  Jquery

如何使用jquery在对象中保存输入值,然后将其保存到数组中

aquasp • 5 年前 • 1605 次点击  

我认为这个标题本身就解释了。我需要将输入值保存在一个对象中,然后将这个对象保存在一个数组中。

<html>
  <head>
    <title>Teste</title>
  </head>
  <script>
    function vai(){
      var pessoa = {
      nome = document.getElementById('nome').value,
      idade = document.getElementById('idade').value
    };
      var i = 0;
      var pessoas = [];
      pessoas[i] = pessoa{};
      i++;
    }

  </script>

  <body>
    <label>Digite seu nome aqui</label>
    <input type='text' id='nome' placeholder='aquii'>
    <label>Digite sua idade aqui</label>
    <input type='text' id='idade' placeholder='aquii'>
    <button onclick='vai()'>
      Teste aqui
    </button>

  </body>
</html>
Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/38277
 
1605 次点击  
文章 [ 2 ]  |  最新文章 5 年前