Using jQuery, what\'s the performance difference between using:
$(\'#somDiv\').empty().append(\'text To Insert\')
and
$(\'
difference between append()
and html()
in jQuery
.append()
and .html()
are the most useful methods in jQuery. But these are far different from one another, .append()
add some value to the existing one. Where .html()
do the same but it removes the old value first.
Here is an example:
- test
Now I will use .append()
to add one , For that I will write:
The output of this jQuery will be:
- test
- test1
Now if I use .html()
to add one , For that I will write:
The output of this Script will be:
- test1
Here in this example .append()
add one extra , whether
.html()
removes the old one with new one. This is the main difference between .append()
and .html()
in jQuery.