Auto update div content while typing in textarea using jQuery

  4103 views   2 years ago jQuery

Use the jQuery keyup() method

You can use the jQuery keyup() method in combination with the val() and text() method to simultaneously update the <div> element content, while user writing the text in a <textarea>.

Let's try out the following example to understand how it basically works:

<!DOCTYPE html>
<html lang="en">
<meta charset="utf-8">
<title>jQuery Auto Update Div with Content from Textarea</title>
        padding: 10px;
        min-height: 50px;
        border: 1px solid #e4e4e4;
<script src=""></script>
        // Getting the current value of textarea
        var currentText = $(this).val();
        // Setting the Div content
        <textarea id="myTextarea" rows="5" cols="60" placeholder="Type something here..."></textarea>
    <div class="output"></div>


Author : Harsukh Makwana
Harsukh Makwana

Hi, My name is Harsukh Makwana. i have been work with many programming language like php, python, javascript, node, react, anguler, etc.. since last 5 year. if you have any issue or want me hire then contact me on [email protected]