简体   繁体   中英

Show message in HTML textarea by id

I'm making a chat application in a pop up mode in the corner of the website. I'm using SignalR for the chat in ASP.NET, C#. The problem is, that not showing the message in the textarea. Here is my code for my HTML file:

 <div class="chat-popup" id="myForm"> <form action="/Wilcome" class="form-container"> <h1>Chat</h1> <label><b>Message</b></label> <textarea id="messagesList" readonly></textarea> <textarea placeholder="Type message.." id="messageInput"></textarea> <button type="button" class="btn" id="sendButton">Send</button> <button type="button" class="btn cancel" onclick="closeForm()">Close</button> </form> </div>

The id="messagesList is not showing. This is in my chat.js file, where showing the sent messages. When I tried to use in a simple <ul id="messagesList"></ul> thats worked but in a lots of messages its going to the infinity up and cant scroll down, so its better to make in textarea (i found only this one for it, if you can tell any one like this textarea, please share)

You can actually apply a scrollbar to more elements than the textarea.

You can have a div, give it a height in CSS and set its overflow-y to scroll

<div id="messagesList"></div>

#messagesList{
   height:300px;
   overflow-y:scroll
}

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