В каком случае лучше использовать.append (), а какой.appendTo ()?

Между этими функциями нет большой разницы, кроме синтаксиса :

$('.target').append('text');
$('text').appendTo('.target');

. Как сказано в jQuery docs:

The.append() and.appendTo() methods perform the same task. The major difference is in the syntax-specifically, in the placement of the content and target. With.append(), the selector expression preceding the method is the container into which the content is inserted. With .appendTo(), on the other hand, the content precedes the method, either as a selector expression or as markup created on the fly, and it is inserted into the target container.

Так в каком случае лучше использовать.append (), а какой.appendTo ()? В каком коде -выборки соответствуют только одной из этих двух функций, а другая недостаточно хороша?

Тот же вопрос относится к:

8
задан webvitaly 18 July 2012 в 08:19
поделиться