空白で分割する

書式

$w(string)

string : 文字列

説明

文字列を半角の空白で分割するには$w()を使います。分割された文字列は配列として返されます。これはsplit(" ")と同じ結果になります。

サンプルコード [実行]

<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<title>Sample</title>
<link rel="stylesheet" href="main.css" type="text/css" media="all">
<script type="text/javascript" src="prototype.js"></script>
<script type="text/javascript"><!--
window.onload = function() {
var text = "Sample of prototype.js";
$("result").innerHTML = $w(text);
}
// --></script>
</head>
<body>
<h1>空白で分割</h1>
<div id="result"></div>
</body>
</html>