Getting value of textarea by JavaScript function

Type any samples code

Hi @skenazi, welcome to the forum. I’m sorry, but your question is unclear. Could you please explain it in more detail?

<!DOCTYPE html>
<title>Get Values Of Form Elements Using jQuery</title>
<!-- Include CSS File Here -->
<link rel="stylesheet" href="form_value.css"/>
<!-- Include JS File Here -->
<script src="\test\jquery\jquery.min.js"></script>
<script type="text/javascript">

// To get value of textarea.
$('#textarea_value').click(function() {
var textarea_value = $("#textid").val();
if(textarea_value=='') {
alert("Enter Some Text In Textarea");
$('#textarea_reset').click(function() {
<div class="container">
<div class="main">
<h2>Get Values Of Form Elements Using jQuery</h2>
<form action="">
<!-- Textarea -->
<label>Textarea :</label>
<textarea id="textid" ></textarea>
<input type="button" id="textarea_value" value="Get Value"/>
<input type="button" id="textarea_reset" value=" Reset "/>

@skenazi — make sure to say a bit about what your issue is, explain what you’ve tried, what you’re seeing etc. Otherwise the thread feels a bit odd. :slight_smile:


you’re calling the script too early, at a point where your target elements don’t exist yet.

You are correct that the code needs to come after where the resource is pulled in.
But also it needs to run after the page contents have been loaded in.

A typical way is to put the code in <script> tags just before the closing </body> tag.

Yes. I do it and it’s run fine . Thanks for all . And to this fourm.

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.