Add text to the bottom of a div (or another element) - emulating chat console

前端 未结 3 1092
北恋
北恋 2021-01-06 12:42

I have a div that should be collecting text as text is entered into the input box (right now it just reproduces the input, but later it should produce semi-intelligent respo

3条回答
  •  情歌与酒
    2021-01-06 13:20

    If you use

    $("#prisonerResponse").html(responseTxt + '\n');
    

    it will replace all content with the new one.

    If you just want to add it at the end, use append:

    $("#prisonerResponse").append(responseTxt + '\n');
    

提交回复
热议问题