简体   繁体   中英

Making specific text in textarea bold

I am making an chatbox in which for displaying chat history I used textarea which is readonly.... what I want is to make the starting text "Me: " Bold

document.getElementById(messagearea).value = 
document.getElementById(messagearea).value + "\n <b>Me:</b>" + message1;

Any help?

It's not possible to format part of the text in a textarea. Instead place the text in a <div> .

<div id="messages" style="white-space: pre-wrap"></div>

With jQuery:

$('#messages').append("<div><b>Me:</b>" + message1 + "</div>")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM