문제

When using .append(someHTMLElement) on a jQuery multiselection, does jQuery clone the element to append automatically?

Example:

var newElement = $("<p>Some text</p>");
var myElements = $(".multiselector").append(newElement);

Does this add newElement to all of the elements contained in myElements?

도움이 되었습니까?

해결책

From the docs

The .append() method inserts the specified content as the last child of each element in the jQuery collection

So yes it copies to all selected elements.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top