What is the difference between jQuery: text() and html() ?

后端 未结 16 1704
傲寒
傲寒 2020-11-22 03:45

What the difference between text() and html() functions in jQuery ?

$(\"#div\").html(\'Linkhello\         


        
16条回答
  •  無奈伤痛
    2020-11-22 04:43

    The first example will actually embed HTML within the div whereas the second example will escape the text by means of replacing element-related characters with their corresponding character entities so that it displays literally (i.e. the HTML will be displayed not rendered).

提交回复
热议问题