tags:

views:

50

answers:

4

Hello,

I have a <input type="hidden" value="" id='h_v' class='h_v'> Using jQuery I want to alert the user to this value .

I am using

var hv = $('#h_v).text();
alert('x');

But its not working, any clues!

Thanks Jean

A: 

Closing the quotes in var hv = $('#h_v).text(); would help I guess

Coronier
`.text()` is not working on input-fields. rather use `.val()`
Andreas Niedermair
+3  A: 

Use val() instead of text()

var hv = $('#h_v').val();
alert(hv);

You had these problems:

  • Single quotes was not closed
  • You were using text() for an input field
  • You were echoing x rather than variable hv
Sarfraz
I am trying to trigger this alert with an append, and the hidden field is in the append div.
Jean
@Jean: I don't undertand that, please be more specific.
Sarfraz
Please check for the updated questionhttp://stackoverflow.com/questions/3091670/get-value-from-hidden-field-after-append-jquery
Jean
+1  A: 

This should work:

var hv = $('#h_v').val();
alert(hv);
Lukasz Dziedzia
+1  A: 

var x=$('#h_v').val(); alert(x);

Cris