Preserve newlines when setting html in a div from a textarea - Jquery

前端 未结 1 866
时光取名叫无心
时光取名叫无心 2021-01-28 09:37

I got this little html -:

1条回答
  •  悲哀的现实
    2021-01-28 10:14

    The new lines are preserved, but not converted to HTML new lines (
    ), so they are ignored.

    You can convert them to
    with .replace:

    $("#copyToDiv").on("click",function(){ $("#viewOne").html( $("#viewTwo").val().replace("\n","
    ") ) });

    0 讨论(0)
提交回复
热议问题