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

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

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

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


        
16条回答
  •  既然无缘
    2020-11-22 04:42

    I think that the difference is to insert html tag in text() you html tag do not functions

    $('#output').html('You are registered'+'
    ' +' ' + 'Mister'+' ' + name+' ' + sourname ); }

    output :

    You are registered 
    Mister name sourname

    replacing text() with html()

    output

    You are registered
    Mister name sourname 
    

    then the tag
    works in html()

提交回复
热议问题