1

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 !

1
  • 2
    Why do you think that jQuery provides any such .split() method? It does not. Commented Aug 28, 2012 at 17:39

1 Answer 1

6

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"
Sign up to request clarification or add additional context in comments.

2 Comments

The OP also needs to initialize var arr = [].
thanks guys it work ! But i can accept your awnser after 11 minutes

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.