RussellHarrower
RussellHarrower

Reputation: 6820

jQuery seems to not split

I am using the following code that contains a call to split a list of ids.

$("#editlisting").live('click', function(event) {
    //alert("hello");
    editlistingid = $("tbody td.small input:checkbox:checked").map(function(i, el) {
        return $(el).attr("id"); 
    }).get();
    eid = editlistingid.split(",");
    alert(eid[0]);
    editlead();
});

However, what I am finding is that it is not getting split at all.

Upvotes: 0

Views: 80

Answers (1)

alex
alex

Reputation: 490647

editlistingid will hold an Array, as the result of get() was assigned to it.

Without a parameter, .get() returns all of the elements:

alert($('li').get());

All of the matched DOM nodes are returned by this call, contained in a standard array.

Source.

split() works on a String.

Splits a String object into an array of strings by separating the string into substrings.

Source.

You are trying to call a String method on an Array. That won't work.

It looks like you could use editlistingid directly.

Upvotes: 3

Related Questions