Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to show text while typing in textarea in jquery

Tags:

html

jquery

php

i looking for a way to preview the text while im typing in a textarea in jquery

exactly what u are using for Stackoverflow ,

like image 319
Mac Taylor Avatar asked Apr 21 '10 15:04

Mac Taylor


People also ask

How to use text and textarea input in jQuery Mobile?

The <textarea> tag allows the user to input text over multiple rows. Following example demonstrates the use of text and textarea input in the jQuery Mobile. Save the above html code as textinput_text.html file in your server root folder.

What is the use of text method in jQuery?

jQuery text() Method jQuery HTML/CSS Methods. Example. ... Definition and Usage. The text() method sets or returns the text content of the selected elements. When this method is used to return content, it returns the text content of all matched elements (HTML markup will be removed).

What is the use of text in HTML?

Definition and Usage. The text() method sets or returns the text content of the selected elements. When this method is used to return content, it returns the text content of all matched elements (HTML markup will be removed). When this method is used to set content, it overwrites the content of ALL matched elements.

How do I get the text content of a selected element?

$ ("p").text("Hello world!"); The text () method sets or returns the text content of the selected elements. When this method is used to return content, it returns the text content of all matched elements (HTML markup will be removed).


1 Answers

<script>
  $(document).ready(function () {
    $('#someTextBox').keyup(function(){
      $('#target').html($(this).val());
    });
  });
</script>

<textarea id="someTextBox"></textarea>
<div id="target"></div>

As you type text in the <textarea>, the text should be duplicated in the HTML of the <div>.

like image 97
Justin Niessner Avatar answered Sep 19 '22 23:09

Justin Niessner