English 中文(简体)
str.split(文件)在美元(文件)内行不通?
原标题:str.split() inside $(document).ready() does not work?

rel=“nofollow>http://jsfiddle.net/MQHkA/2/

$(document).ready(function() {
    var mystring="fusioncharts,om,bdutt";
    var arr = mystring.split( , ); //array returned
    for(var i = 0; i < arr.length; i++) {
      alert(arr[i]);
    }
}

上述法典是否可行?

EDIT-----

真正的法典是:

handle1 = getUrlVars();
if(handle1 ==   ) {
    $("input#handle1").val( barackobama );
    $("input#handle2").val( aplusk );
    $("input#handle3").val( charliesheen );
    handle1 =  barackobama,aplusk,charliesheen ;
} else {
    alert(handle1);       // this says fusioncharts,om,bdutt
    var queryvals = [];
    queryvals = handle1.split( , );
    alert( length +queryvals.length);         // *** this says nothing ***
    for(var i = 0; i < queryvals.length; i++) {
        alert(queryvals[i]);                   // *** nothing here too.. ****
    }
}

整块都在(文件)面。

我无法发现一些简单的错误。

最佳回答

you are missing the closing parentheses other than that it works fine

$(document).ready(function() {
    var mystring="fusioncharts,om,bdutt";
    var arr = mystring.split( , ); //array returned
    for(var i = 0; i < arr.length; i++) {
      alert(arr[i]);
    }
}); // this one is missing on yours
问题回答

是的,但你必须结束榜样。

);

http://jsfiddle.net/gMU9t/。

你想结束你的亲子关系,已经敲响了警钟。 在提出要求之前,不要修改你的法典。 Java字功能是罚款。 你们需要更加关注。





相关问题
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.

热门标签