[英]How to replace <br /> fromTextBox
當我在文本框中插入一個值時,當我按Enter鍵插入換行符時,我得到一個<br />
標記。 我應該如何刪除<br />
標記並使用jQuery替換換行符。
$('#dbDocumentFooter').keyup(function(e){
var TextToBeDisplayed = $(this).val();
if(e.keyCode == 13 && !e.shiftKey) {
TextToBeDisplayed = $('#dbDocumentFooter').val().replace("\n", "<br />", "g")
$('#dbDocumentFooter').val(TextToBeDisplayed);
}
});
試試這個https://jsfiddle.net/qa3q9w3r/
$('#dbDocumentFooter').keydown(function(e){
if(e.keyCode == 13 && !e.shiftKey) {
e.target.value+="\n";
e.preventDefault();
}
});
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.