简体   繁体   English

在 HTML textarea by id 中显示消息

[英]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#.我在 ASP.NET、C# 中使用 SignalR 进行聊天。 The problem is, that not showing the message in the textarea.问题是,没有在文本区域中显示消息。 Here is my code for my HTML file:这是我的 HTML 文件的代码:

 <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) id="messagesList没有显示。这是在我的chat.js文件中,显示发送的消息。当我尝试在一个简单的<ul id="messagesList"></ul>中使用时,它可以工作但很多消息它会无限向上并且不能向下滚动,所以最好在 textarea 中制作(我只找到了这个,如果你能告诉任何喜欢这个 textarea 的人,请分享)

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,在 CSS 中给它一个高度,并将其溢出-y 设置为滚动

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

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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