jQuery API | jQuery API 中英文对照版 - jQuery在线查询手册 |
clone |
clone(deep)
克隆匹配的DOM元素并且选中这些克隆的副本。 在想把DOM文档中元素的副本添加到其他位置时这个函数非常有用。 返回值:jQuery 参数:
克隆所有b元素(并选中这些克隆的副本),然后将它们前置到所有段落中。 $("b").clone().prependTo("p"); HTML 代码: <b>Hello <span>world</span></b><p>, how are you?</p> 结果: <b>Hello <span>world</span></b><p>Hello <span>world</span></b>, how are you?</p> clone( deep ) 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: Clones all b elements (and selects the clones) and prepends them to all paragraphs. $("b").clone().prependTo("p");Before: <b>Hello</b><p>, how are you?</p>Result: <b>Hello</b><p><b>Hello</b>, how are you?</p> |