Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jquery - how to explode arrays value

Is it possible to explode datas in array according to a charachter?

.each(myArr, function(key, value) { 

});

i take array like that

value is the values of array . Can explode value with "-" ?

like image 466
snnlankrdsm Avatar asked Apr 27 '12 09:04

snnlankrdsm


People also ask

How to explode value in jQuery?

Answer: Use the JavaScript split() method If you want to explode or split a string from a certain character or separator you can use the JavaScript split() method. The following example will show you how to split a string at each blank space. The returned value will be an array, containing the splitted values.

How do you iterate in jQuery?

each(), which is used to iterate, exclusively, over a jQuery object. The $. each() function can be used to iterate over any collection, whether it is an object or an array. In the case of an array, the callback is passed an array index and a corresponding array value each time.


2 Answers

Use split():

var items = value.split('-');
like image 61
ThiefMaster Avatar answered Sep 19 '22 19:09

ThiefMaster


You can use split

 var arr = str.split('-');
like image 35
Bibin Velayudhan Avatar answered Sep 17 '22 19:09

Bibin Velayudhan