What is the difference between .empty().append() and .html()?

前端 未结 6 1217
心在旅途
心在旅途 2020-12-18 08:27

Using jQuery, what\'s the performance difference between using:

$(\'#somDiv\').empty().append(\'text To Insert\')

and

$(\'         


        
6条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-18 09:23

    In simple words:

    $('#somDiv').append('blabla')
    

    works like this:

    some text

    becomes:

    some textblabla

    And innerHTML replaces the contents, so it becomes this:

    blabla

提交回复
热议问题