Вопрос

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