Solved

Display text on website using a textbox with jQuery

Posted on 2012-12-27
4
379 Views
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>

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

</head>

<body>

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



<script>
$("#box").keypress(function() {
    var $this= $(this);
    window.setTimeout(function() {
       $("#div_one").text($this.val());
    }, 0);
});
</script>

</body>

</html>

Open in new window

0
Comment
Question by:ats2012
  • 3
4 Comments
 
LVL 31

Accepted Solution

by:
GwynforWeb earned 500 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

0
 

Author Closing Comment

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

Author Comment

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

Author Comment

by:ats2012
ID: 38726877
Nevermind I got it working
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction HyperText Transfer Protocol (http://www.ietf.org/rfc/rfc2616.txt) or "HTTP" is the underpinning of internet communication.  As a teacher of web development I have heard many questions, mostly from my younger students who have come to t…
Introduction Got endorsements from your clients?  Great!  There is almost nothing better than word-of-mouth advertising.  But how can you do that on the internet?  Sure you can make a page for endorsement quotations and list them all, but who is …
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)

810 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