Random78952
Random78952

Reputation: 1640

jQuery split array problems

i had try to make a split with jQuery on a array field but it dosen't work :

var arr;
arr[0] = 'size:256';
var vals = $(arr[0]).split(':');
alert(vals);​

Why ?

Thanks !

Upvotes: 1

Views: 1154

Answers (1)

VisioN
VisioN

Reputation: 145408

There is no need in jQuery, just pure JavaScript. String split is native JS function.

var arr = [];     // and don't forget to initialize array
arr[0] = 'size:256';

var vals = arr[0].split(':');
alert(vals[0]);   // gives "size"
alert(vals[1]);   // gives "256"

Upvotes: 6

Related Questions