jQuery wrapInner()メソッド
例
各<p>要素のコンテンツの周りに<b>要素をラップします。
$("button").click(function(){
$("p").wrapInner("<b></b>");
});
定義と使用法
wrapInner()メソッドは、選択された各要素のコンテンツ(innerHTML)の周りに指定されたHTML要素をラップします。
構文
$(selector).wrapInner(wrappingElement,function(index))
Parameter | Description |
---|---|
wrappingElement | Required. Specifies what HTML element(s) to wrap around the content of each selected element Possible values:
|
function(index) | Optional. Specifies a function that returns the wrapping element
|
自分で試してみてください-例
するdocument.createElement()を使用して要素を作成し、選択した各要素のコンテンツにラップする方法。
を使用して、選択した各要素のコンテンツをラップする対象を指定します。