JQUERYテキスト関数を使用してtextareaからDIVにコンテンツを置き換えている間、brタグが機能していません

ラマリンガムペルマル

brタグがDIVで機能していません。Update Content:textareaフィールドからメッセージを受け取ります。メッセージには、「Rama」の次の行「Lingam」のような2行があります。でも結果は「
ラマリンガム」$("#editQuotesRowLabel_Q_013").text(replaceContent);

DIVで改行する方法は?

これが私のコードです:

function updateQuotes(){    
    var weg_quotes = $("#weg_quotes_Q_013").val();  
    replaceContent = weg_quotes.replace("\n", "<br>", "g");         
    $("#editQuotesRowLabel_Q_013").text(replaceContent);
}
Update Content: <textarea placeholder="Update your content..." id="weg_quotes_Q_013" name="weg_quotes" cols="80" rows="3" class="appQuotesTextarea" maxlength="200" required=""></textarea>
<button onclick="updateQuotes()" id="Q_013" name="update-btn" class="appQuotesBtn">Update</button>

<div id="editQuotesRowLabel_Q_013" class="appQuotesLabel">
    This is content div. 
</div>
ismnoiet

jqueryを使用してHTMLコンテンツを挿入するには、の.html()代わりにを使用する必要があります.text()したがって、あなたの場合、あなたは次のようになります:

 $("#editQuotesRowLabel_Q_013").html(replaceContent);
 //                              |_ use html() instead of text()

出典:

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

Related 関連記事

ホットタグ

アーカイブ