<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title></title> <script src="scripts/jquery-1.7.2.js"></script> <script type="text/javascript"> function btnquzhi() { var MyDiv = document.getElementById("divTJ"); new=Arwhere Array (); Ar.push({ key: '1', qid: '1', name: '张三1', value: '123' }); Ar.push({ key: '2', qid: '2', name: '张三2', value: '123' }); Ar.push({ key: '3', qid: '3', name: '张三3', value: '123' }); Ar.push({ key: '4', qid: '4', name: '张三4', value: '123' }); debugger for (var i = 0; i < Ar.length; i++) { MyDiv.innerHTML += "<input value=" + Ar[i]['key'] + " />" + "<input value=" + Ar[i]['qid'] + " />" + " <input value = " + Ar[i]['name'] + " />" + "<input value=" + Ar[i]['value'] + " /><br />"; } } </script> </head> <body> <span onclick="btnquzhi()">取值</span> <div id="divTJ"> </div> </body> </html>
Interface to obtain an array of values to a set value method can directly see the code for the loop parameters on compatibility will be much better results are as follows.