Display text on website using a textbox with jQuery

Posted on 2012-12-27
Medium Priority
Last Modified: 2012-12-28
I have some code where you type some text in a textbox and it will display under it. What i would like is instead of using keypress I am looking for it copying the text box so right now when you back space it wont delete it until you press another key. Is this possible? Below is the code I am using.

<!DOCTYPE html>

<script src="jquery.js" language="javascript" type="text/javascript"></script>
<title>Display text</title>



<input type="text" value="" id="box"/>
<div id="div_one"></div>

$("#box").keypress(function() {
    var $this= $(this);
    window.setTimeout(function() {
    }, 0);



Open in new window

Question by:ats2012
  • 3
LVL 31

Accepted Solution

GwynforWeb earned 2000 total points
ID: 38725091
Use onkeyup, eg try this

<p><input type="text" onkeyup="document.getElementById('myDiv').innerHTML=this.value"> </p>
<div id="myDiv"></div>

Open in new window


Author Closing Comment

ID: 38725104
This is what I was looking for. Thanks

Author Comment

ID: 38726866
There a fix for Internet Explorer? It works great in Chrome but all my users will be using IE.

Author Comment

ID: 38726877
Nevermind I got it working

Featured Post

Train for your Pen Testing Engineer Certification

Enroll today in this bundle of courses to gain experience in the logistics of pen testing, Linux fundamentals, vulnerability assessments, detecting live systems, and more! This series, valued at $3,000, is free for Premium members, Team Accounts, and Qualified Experts.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
How to build a simple, quick and effective accordion menu using just 15 lines of jQuery and 2 css classes
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

627 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question