[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

Display text on website using a textbox with jQuery

Posted on 2012-12-27
4
Medium Priority
?
387 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
4 Comments
 
LVL 31

Accepted Solution

by:
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

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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

How to build a simple, quick and effective accordion menu using just 15 lines of jQuery and 2 css classes
A while back, I ran into a situation where I was trying to use the calculated columns feature in SharePoint 2013 to do some simple math using values in two lists. Between certain data types not being accessible, and also with trying to make a one to…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. 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…
Suggested Courses

650 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