English 中文(简体)
2. 混合使用量在变数中?
原标题:Use Comma in variable?

是否有办法改变这种状况:

$( #id ).testfunction({
   source  : [
    { source : pathimage.jpg , title : Title 1 , description : This is a description 1. },
    { source : pathimage.jpg , title : Title 2 , description : This is a description 2. },
    { source : pathimage.jpg , title : Title 3 , description : This is a description 3. },
    { source : pathimage.jpg , title : Title 4 , description : This is a description 4. },
    { source : pathimage.jpg , title : Title 5 , description : This is a description 5. }
  ]
});

简单易举的产出:

$( #id ).testfunction({
   source :[
    $SOURCE
  ]
});

我是个阵列,并试图将其重新编成一个阵列。 缩略语

$SOURCE = myArray[0], myArray[1], myArray[2], myArray[3], myArray[4];

But its the comma thingy that keeps prevent the variable from working. I can t get the comma into the variable. Using + "," + doesnt work since it recognizes it as a string...

$SOURCE += myArray[s],;

是否有办法将这一变量转化为有活力的使用?

最佳回答

否,因为如果<代码>(SOURCE)是一个阵列,那么你将分配一个阵列到<代码>><源代码/代码>参数的第一个要素上;<代码>SOURCE则代表一个阵列,以你预期能够做到。

没有任何法律结构可以把变数与 com合在一起。

问题回答

你们想要把一个阵列的一些价值观放在另一个阵列。 这应当奏效,但似乎对我来说是一种冒犯(或者说你可以穿过我的阿雷拉,或者你可以说:$SOURCE = 我的阿莱):

$SOURCE = [];
$SOURCE.push(myArray[0]);
$SOURCE.push(myArray[1]);
$SOURCE.push(myArray[2]); 
$SOURCE.push(myArray[3]); 
$SOURCE.push(myArray[4]);




相关问题
selected text in iframe

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.

How to fire event handlers on the link using javascript

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 ...

How to Add script codes before the </body> tag ASP.NET

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 ...

Clipboard access using Javascript - sans Flash?

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 ...

javascript debugging question

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 ...

Parsing date like twitter

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.

热门标签