Thursday, November 20, 2008

How to split a string using javascript - split() method

Following code will show you how to split a string using a given separator.



<head>

<script type="text/javascript">

var my_string = "Hello My Name Is Kusal";
var split_var = my_string.split(" "); //separate by space

alert(split_var[0]); //Hello
alert(split_var[1]); //My
alert(split_var[4]); //Kusal

</script>

</head>



Get Free Sinhala IT Learning Videos Kuppiya.com


Get custom programming done at GetAFreelancer.com!

No comments:

Post a Comment