Please Login or Register to continue.


I am creating a project in the JavaScript jQuery library. I want to display text while writing in an HTML text box using jQuery.There is a form where a text box is available inside the form. I want like, whenever start writing in the text box the same text should be displayed on the page. I can use the text area to write my text.

HTML form - 

   <input type="text" name="content" id="content">

As you can see in the above code line, I have created a text box. I have seen many websites where I can display the same text on the page while writing in a text box. 

(2.4K Points)
in jquery


1 Answer
(3.4K Points)

If you are using the JavaScript jQuery library then it will be very easy to display value while typing in the text box. You can do it using the jQuery keyup() method. I also use this keyup() method to get values while typing in the textbox or textarea. You will need to create an HTML text box or you can create a textarea. Give an id name like - id="content" . You will need a jQuery CDN link. Use the jQuery ready() method and keyup() method using the textbox id. 

Create an example - 

<!DOCTYPE html>
   <title>Getting value from the HTML text box while typing in jQuery</title>
<script src="https://code.jquery.com/jquery-3.6.1.min.js"></script>
<script type="text/javascript">
        var content=$("#content").val();
   <p id="display_content"></p>
   <input type="text" name="content" id="content" placeholder="Typing">

You can display content id using the html() method while typing. In this way, you can display text on the page while typing in the textbox or textarea in jQuery.


Related Questions :-

Your Answer

You can post your answer after login..