Jump to: navigation, search

JQuery Array Create with split

From w3cyberlearnings

Contents

jQuery Create Array

Create Array in jQuery uses split() function.

Syntax $.split()

  • myFruits is the string
  • w_sep is the separator
 
myFruits.split(w_sep);

Example 1

$(document).ready(function() {
	var myFruits='Apple Banana Coconut Mango Pear Orange';
	var myFruitsArray = myFruits.split(' ');
				
	alert(myFruitsArray[0]);
});

Output

Apple

Example 2

	
$(document).ready(function() {
	var myFruits='ApplexxxBananaxxxCoconutxxxMangoxxxPearxxxOrange';
	var myFruitsArray = myFruits.split('xxx');
				
	alert(myFruitsArray[2]);
});

Output

Coconut

Related Links


Navigation
Web
SQL
MISC
References