ラップ このラッピング プロセスは、ドキュメントの元のセマンティックな性質を損なうことなく、ドキュメントに追加の構造を挿入する場合に最も役立ちます。提供された最初の要素 (提供された HTML からオンザフライで生成されます) を検索し、その構造内で最も深い祖先要素を見つけます。この要素が他のすべてをラップします。 Return value jQuery
パラメータ html (文字列): 要素を動的に生成し、ターゲット要素をラップするために使用される HTML タグ コード文字列
-------------------------------------------------- -------------------------------------------------- --------------------------------------------- remove([expr]) Remove all matching elements from the DOM. This method does not remove the matching elements from the jQuery object, so you can reuse these matching elements in the future.
Removes all matched elements from the DOM. This does NOT remove them from the jQuery object, allowing you to use the matched elements further. Can be filtered with an optional expression. Return value jQuery
Parameters expr (String): (Optional) jQuery expression for filtering elements
------------- -------------------------------------------------- -------------------------------------------------- -------------------------------- clone() Clone matching DOM elements and select these clones copy of. This function is useful when you want to add a copy of an element in the DOM document to another location.
Clone matched DOM Elements and select the clones . This is useful for moving copies of the elements to another location in the DOM. Return value jQuery
Example Clone all b elements (and select these cloned copies ) and prepend them to all paragraphs.
HTML code:
Hello
, how are you?
jQuery code:
$("b" ).clone().prependTo("p"); Result:
Hello
Hello, how are you?
------------------------------------------------ -------------------------------------------------- ----------------------------------------------- clone(true) element and all its event handlers and select these cloned copies This function is very useful when you want to add a copy of an element to another location in the DOM document.
Clone matched DOM Elements, and all their event handlers, and select the clones. This is useful for moving copies of the elements, and their events, to another location in the DOM. Return value jQuery
Parameters true (Boolean): Set to true to copy all event handlers of the element
Example Create a button that can copy itself, and its copies will have the same functionality.