Reputation: 2975
Will $('#some-field').val()
return "something" or empty string? I assume it would return the value regardless if the div is visible or not. But I have been getting empty string. Any idea?
<div style="display:none;">
<form>
<input id="some-field" type="text" value="something" />
</form>
</div>
Upvotes: 3
Views: 10086
Reputation: 5063
It will return something
. Visibility doesn't play a factor into retrieving values since it stills exist in the DOM.
Upvotes: 4
Reputation: 87073
Try this:
$('div:hidden #some-field').val();
Even $('#some-field').val();
will work also, because visibility doesn't effect, if the element belong to DOM.
Upvotes: 4