var data = {} 这样是在定义什么?没见过
var data = {}
data[ "-1_1 "] = "img: document.images[56].src; url: document.links[2].href; target: _blank; alt: ; ";
data[ "-1_2 "] = "img: document.images[57].src; url: document.links[4].href; target: _blank; alt: ; ";
data[ "-1_3 "] = "img: document.images[58].src; url: document.links[6].href; target: _blank; alt: ; ";
data[ "-1_4 "] = "img: document.images[59].src; url: document.links[8].href; target: _blank; alt: ; ";
data[ "-1_5 "] = "img: document.images[60].src; url: document.links[10].href; target: _blank; alt: ; ";
data[ "-1_6 "] = "img: document.images[61].src; url: document.links[12].href; target: _blank; alt: ; ";
我想把img:后面的值都变成document.images[56].src存储的值,而不是document.images[56].src这个串名;
------解决方案--------------------look this :
var data = {
a:function (){ alert ()},
b: 'aa '
}
------解决方案--------------------JSON是一种JS的基础数据结构
是一种比XML更快捷更高效的数据模型,GOOGLE MAP就是用它做的数据交换
具体看这里
http://www.javaeye.com/topic/71343
http://hi.baidu.com/hibydu/blog/item/ef9b17fab7c1a51ca8d3119e.html
而用function可以定义的是类,两种差不多,但本质上稍微有点区别