admin管理员组文章数量:1355703
I'm implementing a little chat application where I receive messages from a server, which I would like to display to a user. As I'm more of a backend guy, and lacking experience in frontend development, I don't know which element would be suited best to output the text.
Two options e to my mind:
- Using a plain
div
- Using a
textarea
(as far as I understand, this is intended to be used for input).
(Would also be nice if I could somehow fade in the text using JQuery).
I'm implementing a little chat application where I receive messages from a server, which I would like to display to a user. As I'm more of a backend guy, and lacking experience in frontend development, I don't know which element would be suited best to output the text.
Two options e to my mind:
- Using a plain
div
- Using a
textarea
(as far as I understand, this is intended to be used for input).
(Would also be nice if I could somehow fade in the text using JQuery).
Share Improve this question edited Mar 29, 2012 at 17:45 gdoron 150k59 gold badges302 silver badges371 bronze badges asked Mar 29, 2012 at 17:18 helpermethodhelpermethod 62.4k71 gold badges199 silver badges280 bronze badges3 Answers
Reset to default 4- For readonly messages- better use
<div>
- otherwise use
<textarea>
\ textbox(<input type="text"...>
).
Fading it is simple, if the element id is foo
:
$('#foo').fadeIn();
Use a tag for the content and with Jquery you could append a span or a new paragraph tag for every new message:
<div id="chatContent">
</div>
Then in JQuery you could do:
function chatMessageRecieved(message) {
$("#chatContent").append("<p> " + messsage + "</p>")
}
You have to use a div, textarea is effectively for input
For jquery : http://api.jquery./fadeTo/
Ex :
$('#div').fadeTo('slow', 1);
本文标签: javascriptHTMLWhich element to output textStack Overflow
版权声明:本文标题:javascript - HTML - Which element to output text? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1743963986a2569550.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论