Splitting an Array using Javascript
To split an array in Javascript:
var ko = "London,Paris,France";
var ji=ko.split(",");
document.write(ji[0]);
Which prints:
London
-We created an array and named it
ko. We stored three lovely cities in
ko.
-We created a new array and named it
ji. We split the
ko array by commas and stored their pieces in
ji.
-We printed the first item in the
ji array using the index number 0. (index numbers start with 0)
Free Copy and Paste Javascript Code:
<script type="text/javascript">
<!--
var ko = "London,Paris,France";
var ji=ko.split(",");
document.write(ji[0]);
-->
</script>
Resources:
Print to Browser Using Javascript (document.write)
Click HERE to comment or discuss at iLoveTheCode GOOGLE Group
| | | |
CSS David McFarland | | |
| | | |