【发布时间】:2015-05-05 19:35:29
【问题描述】:
html 基础
<html>
<head>
</head>
<body>
<input type="text" class="abc"/>
</body>
</html>
所以我有我的原型对象
function AnArray(){
this.anArray=[];
}
AnArray.prototype.getAnArray=function(val){
return this.anArray[val];
}
AnArray.prototype.setData=function(index,val){
this.anArray[index].data=val;
}
var objAnArray=new AnArray();
对象最终看起来像这样
id: 1, pid: "questions-worth-asking", num: 1, data: null
我正在尝试像这样更改其中的属性
objAnArray.setData(0,$(".abc").eq(0).val());
当我在上述行之前和之后使用 getAnArray() 运行 console.log 消息时,它返回的值与未更改的值相同。
我的问题是如何更改原型对象的属性?
编辑:这个链接让我走上了正确的道路http://www.gpickin.com/index.cfm/blog/websql-when-is-a-javascript-object-not-a-javascript-object
【问题讨论】:
标签: javascript object attributes prototype