jQuery wrap() 方法
jQuery 教程
· 2019-03-27 20:38:34
实例
在 <div> 元素中包裹每个 <p> 元素:
$("button").click(function(){
$("p").wrap("<div></div>");
});
定义和用法
wrap() 方法使用指定的 HTML 元素来包裹每个被选元素。
语法
$(selector).wrap(wrappingElement,function(index))
| 参数 | 描述 |
|---|---|
| wrappingElement | 必需。规定包裹每个被选元素的 HTML 元素。 可能的值:
|
| function(index) | 可选。规定返回包裹元素的函数。
|
点击查看所有 jQuery 教程 文章: https://codercto.com/courses/l/35.html