【发布时间】:2017-10-30 21:37:30
【问题描述】:
想知道是否有可能获取被推入数组的对象的变量或函数 想要将数组中的所有对象添加到函数将获取内容字符串的数组中
我目前拥有的:
recordjs
var recordArray = [];
function EmailRecord(name, email) {
this.name = name;
this.email = email;
this.getRecord = function() {
return this.name+"|"+this.email;
};
}
function addRecord(){
var n1 = document.getElementById("name").value;
var e1 = document.getElementById("email").value
var aRecord = new EmailRecord(n1,e1);
recordArray.push(aRecord);
}
index.html
<label>Name: </label><input type="text" id="name"/>
<label>Email </label><input type="text" id="email"/>
<br/>
<input type="button" value="Add a record" onclick="addRecord()"/>
<p id="p1"></p>
【问题讨论】:
-
所以你想获取变量名还是只获取内容?
-
想要使用的内容
-
你的问题很神秘。请向我们提供一些代码,以便我们更好地了解您要执行的操作。
标签: javascript html