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

前端 未结 4 1803
面向向阳花
面向向阳花 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条回答
  •  春和景丽
    2021-01-02 02:38

    you can probably do it like this

    $('
    ',{class:'error'}).html('Error-Homie!').appendTo($('#header'));

提交回复
热议问题