irfan
irfan

Reputation: 47

Textarea return empty alert , i use all thy way by name ,class , id , but still empty alert in jquery

<textarea name="comt_graph" id="coment_group_value"
    rows="5" style="width:275px; border:1px solid #D6403F;"></textarea>

and jquery code is

$(document).ready(function (){
    $('.group_coment').live('click',function (){
        var coment_val = $('#coment_group_value').val();
        alert(coment_val);
        return false;
    });
});

Upvotes: 1

Views: 87

Answers (3)

chhameed
chhameed

Reputation: 4456

Hi i check it in js fiddle but it work fine for me

Working example

Are you use the developing tools for this ? your code is working...

Error script in another place can make you code stopped working. Try to check your syntax

Upvotes: 2

samir chauhan
samir chauhan

Reputation: 1543

There is no group_coment class in your HTML. Either provide a class in HTMl or write this code for check the value of the textarea.

`$(document).ready(function (){

    var coment_val = $('#coment_group_value').val();
    alert(coment_val);

});`

Upvotes: 0

Chris McFarland
Chris McFarland

Reputation: 6169

From the code you've provided, there is no group_coment class in your HTML.

Either:

  • add class="group_coment" to your textarea element, or
  • change the jQuery selector; replace .group_coment with #coment_group_value

Or, if this is the only textarea element on the page, you could replace .group_coment with textarea.

Upvotes: 1

Related Questions