Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9117993
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T05:01:53+00:00 2026-06-17T05:01:53+00:00

heres a link to the web page s1527.mtchs.org/chat.html When you submit or hit enter,

  • 0

heres a link to the web page s1527.mtchs.org/chat.html

When you submit or hit enter, the value of my textarea is appended to a div. when this happens again, the old value in the div is deleted and appended with the new one? how do I make it so it adds another value instead of deleting the old one?

jQuery:

var captionLength = 0;
var caption = "";

$(document).ready(function()
{
  setInterval ( "cursorAnimation()", 600 );
});

function testTypingEffect()
{ 
if(userInput.value !== "Message")
{
  caption = $("textarea#userInput").val();
  $(caption).append('<div id = content></div>');
  type();
  }
}

function type() 
{
    $('p.caption').html(caption.substr(0, captionLength++));
    if(captionLength < caption.length+1)
    {
        setTimeout("type()", 50);
    }
    else {
        captionLength = 0;
        caption = "";
}   
}
function testErasingEffect()
{
 caption = $("p.caption").html();
  captionLength = caption.length;
 if (captionLength>0)
  {
erase();
 }
 else
  {
$('p.caption').html("You didn't write anything to erase, but ok!");
   setTimeout("testErasingEffect()", 1000);
 }
   }

           function erase()
          {
$('p.caption').html(caption.substr(0, captionLength--));
if(captionLength >= 0)
{
    setTimeout("erase()", 50);
}
else {
    captionLength = 0;
    caption = "";
}   
}

function cursorAnimation() 
{
  $("p.cursor").animate(
 {
   opacity: 0
}, 300, "swing").animate(
 {
 opacity: 1
 }, 300, "swing");
}
$(document).keypress(function(e) {
   if(e.which == 13) {
       testTypingEffect();
  }
});

HTML:

<div id="chatwrapper">
  <div id="tab">chatname</div>
  <div id="content">
    <p id="time"> 2:14:26pm</p>
    <div id="effectTesting">
      <p id="user">\\diablo\\student\2015:</p>
      <p class="caption"></p>
      <p class="cursor">|</p>
    </div>
    <p class="testing"></p>
    <br>
  </div>
  <div id="textarea">
    <textarea id="userInput" onclick="if(this.value=='Message'){this.value=''}" onblur="if(this.value==''){this.value='Message'}">Message</textarea>
    <input type="submit" id="submit" name="submit" value="Submit" onclick="testTypingEffect()"/>
  </div>
</div>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T05:01:55+00:00Added an answer on June 17, 2026 at 5:01 am

    You used .html() instead of .append() on line 21. Changing this was not enough because your dealing with the actual caption length and how to type out the string was not proper so I redid your key functions. See my jsfiddle. I also made it so it adds new content on a new line each time submit is pressed. Also, the cursor will “follow” the content!

    See: http://jsfiddle.net/GJBGt/9/

    HTML:
    Your original HTML

    CSS:

    span{ float:left; clear:both; margin: 5px 0px; overflow: auto;}
    #textarea{ float: left; clear:both}
    .cursor{ display:inline }
    

    JS:

    var caption = "";
    //you REALLY DON'T NEED variable captionLength that you had here before
    
    $(document).ready(function()
    {
      setInterval ( "cursorAnimation()", 600 );
    });
    
    function testTypingEffect()
    { 
    if(userInput.value !== "Message")
    {
      caption = $("textarea#userInput").val();
    
      typefirst();
      }
    }
    
    function typefirst() 
    {
        $('p.caption').append("<span></span>");
        type();
    }
    
    function type()
    {
        $("span").eq(-1).append(caption.substr(0, 1));
        $(".cursor").appendTo($("span").eq(-1));
        if(caption.length > 0)
        {
            caption = caption.substring(1);
            setTimeout("type()", 50);
        }
        else {
            caption = "";
    }   
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i've seen: How to control web page caching, across all browsers? enter link description
Here is link where i got a code for web-page content fetching. But i
Is it possible to link to ONLY a div on a web page? For
I have my html-php web page with form, inputs and sumbit button. With html
I'm using RoR, I will specify a link to a web page in my
I would like to make a link from a web page to a file
In a link in a web page I want to pass a GET parameter
I have a web page with a table and a remove row link in
Right now we have a web page with a bunch of link sections on
Heres my saga - I'm trying to link http://www.example.com to my shopping cart on

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.