Reputation: 5042
There is a textbox that being autocompleted on load. Suppose that it is a email textboxl
$(document).ready(function () {
var email = $("#txtEmail").text();
});
I try to get the value by this code, but it always return null. how to get that email value being autocomplted ?
Upvotes: 0
Views: 310
Reputation: 2180
Check Demo .. i think this is what you actually want
UPDATES
check one more demo
Upvotes: 1
Reputation: 15855
For retrieving value from a input field like textarea, text you have to use val()
and for getting value form a regular html tag like label, span, h1, h2 etc you have to use text()
$('#input_textarea').val(); //right way
$('#input_textarea').text(); // wrong way.returns null
$('#regular_html_tag').text(); // right way
$('#regular_html_tag').val(); // wrong way.It returtns NaN (not a number)
Upvotes: 1
Reputation: 210
you can use if only one input type this link other wise use $("id of emial field").val(); if you have only one input type on your page you can use:
Upvotes: 1