jQuery wrapAll()メソッド
例
すべての<p>要素の周りに<div>要素をラップします。
$("button").click(function(){
$("p").wrapAll("<div></div>");
});
定義と使用法
wrapAll()メソッドは、指定されたHTML要素を選択されたすべての要素にラップします。
構文
$(selector).wrapAll(wrappingElement)
Parameter | Description |
---|---|
wrappingElement | Required. Specifies what HTML element(s) to wrap around the selected elements Possible values:
|
自分で試してみてください-例
するdocument.createElement()を使用して要素を作成し、選択したすべての要素をラップする方法。