jQuery: When creating a new element, do I need the ending tag?

前端 未结 4 1807
面向向阳花
面向向阳花 2021-01-02 01:54
var $div = $(\'
\').appendTo($(\'#header\'));

When creating new elements and adding them to the DOM, do you need the endi

4条回答
  •  Happy的楠姐
    2021-01-02 02:44

    you need the ending tag : http://api.jquery.com/appendTo/ for example

    $('

    Test

    ').appendTo('.inner');

    it should also be

    .appendTo('#header');
    

    and not

    .appendTo($('#header'));
    

提交回复
热议问题