javascript - line breaks in Div -
$("textarea").blur(function() { $("div").html($("textarea").val()); }); $("textarea").blur();
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script> <div></div> <textarea>test123123123123123123123123123123 teateafsdsafsdafaasdf</textarea>
i content in div appear same in textarea (line breaks instead of showing in 1 line).
i've tried set height , width gives me horizontal scroll bar.
use word-break:break-all , give width div should work check snippet
$("textarea").blur(function() { $("div").html($("textarea").val()); }); $("textarea").blur();
div,textarea{ word-break:break-all; width:220px; border:1px solid black; margin:10px; }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <div></div> <textarea>test123123123123123123123123123123 teateafsdsafsdafaasdf</textarea>
hope helps
Comments
Post a Comment