Advertisement
mateon1

Append functions

Jan 3rd, 2014
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function appendHTML(HTML, to) {
  2.     $("#" + to)[0].insertAdjacentHTML('beforeend', HTML);
  3. }
  4.  
  5. function appendChat(text, style, classes, id) {
  6.     var e = $("#chat-messages")[0],
  7.         t = e.scrollTop + e.clientHeight === e.scrollHeight;
  8.     appendHTML("<div "
  9.         + (classes === undefined ? "" : "class=\"" + classes + "\" ")
  10.         + (style === undefined ? "" : "style=\"" + style + "\" ")
  11.         + (id === undefined ? "" : "id=\"" + id + "\"")
  12.         + ">" + text + "</div>", "chat-messages");
  13.     if (t) {
  14.         e.scrollTop = e.scrollHeight;
  15.     }
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement