0

how to deal with value attribute of any element (hidden input in my case)

i have tried with two styles

alert($("#projectManager").attr("value"));

and 

alert($("#projectManager").val());

but it returns 'undefined'.

any help?

1
  • is that within a $(document).ready block? Do elements with those IDs exist? Commented Sep 30, 2009 at 17:10

1 Answer 1

3

Make sure you specify id="projectManager" on the input field. a 'name' attribute is not enough for this selector. And .val() is the way to go to get a field value.

Sign up to request clarification or add additional context in comments.

2 Comments

thank you, i just missed it i have given name instead of id. BTW how did u know i have used name? :-)
Because that's the required attribute for a form element - otherwise you won't get it on the server when submitted :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.