jQuery <textarea> set textarea value

Description

jQuery <textarea> set textarea value

View in separate window

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>jQuery Set Textarea Value</title>
<script src="https://code.jquery.com/jquery-1.12.4.min.js"></script>
<script>
    $(document).ready(function(){
        var textContent = "The quick brown fox jumps over the lazy dog.";
        $("button").click(function(){
            $("#myTextarea").val(textContent);
        });//  w  ww  .j  av  a  2  s .c o m
    });
</script>
</head>
<body>
    <textarea id="myTextarea" rows="3" cols="50"></textarea>
    <br>
    <button type="button">Set Textarea Value</button>
</body>
</html>



PreviousNext

Related