appendChild + createElement

后端 未结 6 774
轻奢々
轻奢々 2020-12-09 09:54

What\'s the difference between:

var div = document.createElement(\'div\');//output -> [object HTMLDivElement]

document.getElementById(\'container\').appe         


        
6条回答
  •  感情败类
    2020-12-09 10:11

    appendChild is expecting an element so when you send it text, it doesn't know what to do. You might want to look into using a javascript library to ease some of that work, such as jQuery. Your code would be:

    $('#container').append('
    ');

提交回复
热议问题