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

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

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

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


        
16条回答
  •  自闭症患者
    2020-11-22 04:36

    var v = "全名";
    $("#div").html(v); //display as "全名"
    $("#div").text(v); //display as "全名"
    

    text() – This method sets or returns the text content of elements selected. html() – This method sets or returns the content of elements selected. Refer example here : https://www.tutorialspoint.com/online_jquery_editor.php

提交回复
热议问题