Source Code:
(back to article)
Submit
Result:
Report an issue
<!DOCTYPE html> <html> <head> <title>Title of the Document</title> <script src="https://code.jquery.com/jquery-3.5.0.min.js"> </script> </head> <body> <p>Type in the textarea and click the button to see the result.</p> <textarea id="comment" rows="5" cols="40"></textarea> <div> <button type="button">Get Value</button> </div> <script> $(document).ready(function() { $("button").click(function() { let comment = $.trim($("#comment").val()); if(comment != "") { alert(comment); } }); }); </script> </body> </html>