Copying text of textarea into div with line breaks

前端 未结 5 1940
春和景丽
春和景丽 2020-12-31 09:15

I am tying to make a simple effect using keyup() in jQuery. I just want that when user types into the textarea then the text which user types will

5条回答
  •  -上瘾入骨i
    2020-12-31 09:39

    Try like

    var value = $(this).();
    var contentAttr = $(this).attr('name');
    
    $('.'+contentAttr+'').html(value.replace(/\r?\n/g,"
    "));

    This is the DEMO

提交回复
热议问题