- Prototype 教程
- Prototype - 主頁
- Prototype - 簡要概述
- Prototype - 有用功能
- Prototype - 實用方法
- Prototype - Element 物件
- Prototype - 數字處理
- Prototype - 字串處理
- Prototype - 陣列處理
- Prototype - 雜湊處理
- Prototype - 基本物件
- Prototype - 模板化
- Prototype - 列舉
- Prototype - 事件處理
- Prototype - 表單管理
- Prototype - JSON 支援
- Prototype - AJAX 支援
- Prototype - 表達範圍
- Prototype - 週期性執行
- Prototype 有用資源
- Prototype - 快速指南
- Prototype - 有用資源
- Prototype - 討論
Prototype - $w() 方法
$w() 函式將字串拆分為一個數組,將所有空格視為定界符。
語法
$w(String);
返回值
一個字串陣列。
示例
<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>
輸出
prototype_utility_methods.htm
廣告