- Prototype 教程
- Prototype - 主頁
- Prototype - 簡短概述
- Prototype - 有用的功能
- Prototype - 實用方法
- Prototype - 元素物件
- Prototype - 數字處理
- Prototype - 字串處理
- Prototype - 陣列處理
- Prototype - 雜湊處理
- Prototype - 基本物件
- Prototype - 模板
- Prototype - 列舉
- Prototype - 事件處理
- Prototype - 表單管理
- Prototype - JSON 支援
- Prototype - AJAX 支援
- Prototype - 表達範圍
- Prototype - 週期性執行
- Prototype 有用資源
- Prototype - 快速指南
- Prototype - 有用資源
- Prototype - 討論
Prototype - wrap() 方法
此方法將一個元素包裝到另一個元素的內部,然後返回包裝。
語法
element.wrap(element, wrapper[, attributes]); OR someElement.wrap(wrapper[, attributes]);
返回值
一個 HTML 元素。
示例
<html>
<head>
<title>Prototype examples</title>
<script type = "text/javascript" src = "/javascript/prototype.js"></script>
<script>
function showResult() {
$('test').wrap( $("bold") );
}
</script>
</head>
<body>
<p id = "test">Formatted Paragraph</p>
<b id = "bold">Above Paragraph should be wrapped here....<br /></b>
<br />
<input type = "button" value = "Click" onclick = "showResult();"/>
</body>
</html>
輸出
prototype_element_object.htm
廣告