arr[key] = value;
<代码>key为j Query Object and Value
为一阵。
arr[key] = value;
<代码>key为j Query Object and Value
为一阵。
Java没有真正的联系阵列。 但是,你可以使用 Java本标语实现类似的功能:
// Create object
var myObject = {
key: value,
helloText: "Hello World!"
};
// Access object in some statement via:
myObject.helloText
// ...or:
myObject["helloText"]
为了把物体用作钥匙,你必须做如下事情:
var a = {
helloText: "Hello World!"
};
var b = {};
b[a] = "Testing";
alert(b[a]); // Returns "Testing" (at least, in Safari 4.0.4)
然而,将物体作为关键物加以使用,是一条轨道。 你们是否认为有必要这样做?
<>Update:
页: 1 上述代码看来是:在<代码>b[a] = “试验”;、Java 份标本转换成<代码>a到通过<代码>a.toString (进行扼制,结果载于[目标]>>
,并利用string作为钥匙。 因此,我们的发言实际上是b[“[目标]”]=“试验”;
,我们的警示声明与alert(b[[[目标]]]”;
。
借助CMS,在评论中指出这一点!
<><>上>
Tim Down 指出,他的 Java本图书馆jshashtable
允许你将物体用作钥匙。
您可使用jshashtable,该文本允许任何 Java本标为关键。
在这里进行公正的猜测,但似乎你试图将一些(任意)数据与 j子(可能是一个要素)联系起来。 在这种情况下,为什么不使用>tdata(方法?
$( #el ).data (value);
你可以将物体用作钥匙,而阵列并不是 Java稿中看起来的,因为如果你通过<代码>.length<>/code>在当地对你确定的人工界定的特性进行清点时,你会把财产放在阵列上。
我建议把字面内的所有物体内的各种元素和阵列都储存在阵列内。 例如:
var list = [
{
el:document.body,
arr:[1,2]
}
];
for ( var i = 0, l = list.length; i<l; ++i ) {
alert( list[i][ el ] )
alert( list[i][ arr ][0] )
}
// add elements to the array
list.push({
el:document.body.firstChild,
arr:[3,4]
})
如他在答复中提到的,如果你使用 Java文的话,最好使用<代码>(<>>/代码>。
if ( !$(el).data( key ) ) {
$(el).data( key , [2,3,4] );
}
我建议为你希望放在联系集装箱(在联合材料中标的)的每个要素指定一个独一无二的识别码,并将该识别资料作为关键:
var idCounter = 0;
var container = { };
function storeValue(element, value) {
if (!element.getAttribute( id )) {
element.setAttribute( id , makeID());
}
var id = element.getAttribute( id );
container[id] = value;
}
function makeID() {
return unique-id- + idCounter++;
}
EDIT:这一解决办法假定无法提供酒类。 如果是,使用<代码>数据(关键,价值)代码>。
每一 j都是一个联系阵列,是一种以语言建造的财产,你不需要任何特殊用途,只是像这样使用。
How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.
I would like to click a link in my page using javascript. I would like to Fire event handlers on the link without navigating. How can this be done? This has to work both in firefox and Internet ...
Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...
Is there a reliable way to access the client machine s clipboard using Javascript? I continue to run into permissions issues when attempting to do this. How does Google Docs do this? Do they use ...
I have a large javascript which I didn t write but I need to use it and I m slowely going trough it trying to figure out what does it do and how, I m using alert to print out what it does but now I ...
Is it possible for someone to give me a few pointers on how to display a multidimensional array in the form of a bar graph? The array is multidimensional, with three elements in each part - and the ...
Is it possible to reload a form after file-input change? I have a form where the user can chose an image for upload. I also have a php script which displays that image resized. I only wonder if it ...
I ve made a little forum and I want parse the date on newest posts like twitter, you know "posted 40 minutes ago ","posted 1 hour ago"... What s the best way ? Thanx.