Tutorials Point


  Learn Prototype
  Prototype Resources
  Selected Reading

Copyright © 2014 by tutorialspoint



  Home     References     Discussion Forums     About TP  

Prototype $w() Method


previous next AddThis Social Bookmark Button


Advertisements

The $w() function splits a string into an Array, treating all whitespace as delimiters.

Syntax:

$w(String);

Return Value:

  • An array of strings.

Example:

<html>
<head>
<title>Prototype examples</title>
<script type="text/javascript" 
   src="/javascript/prototype.js">
</script>
<script>

function ShowValues()
{
   var str = "Apples Bananas Kiwis";

   // Convert string into Array
   var arr = $w(str);

   arr.each(function(value){
		alert(value);
   });

}
</script>
</head>

<body>

   <p>Click "Show Value" button to see the result</p>

   <form>
   <input type="button" value="Show Value" onclick="ShowValues();"/>
   </form>

</body>
</html>

To understand it in better way you can Try it yourself.



previous next Printer Friendly

Advertisements


  

Advertisements