-6

I have one text box and have written "ABC" in the text box, but I want to obtain the text using jQuery

<input type=text value="ABC"> 

But when I use jQuery's .html() it returns null

4
  • .val() you want to use Commented Jan 23, 2014 at 21:18
  • Input tags have no content as they are self closing. Thus text() and html() will return nothing. Commented Jan 23, 2014 at 21:19
  • @Enijar Quotes are optional Commented Jan 23, 2014 at 21:19
  • is this really hard to research online? Commented Jan 23, 2014 at 21:25

1 Answer 1

1

Here's a FIDDLE

<input type="text"> <span></span> 

$('input').keyup(function() { $('span').text($(this).val()); }); 

or

$('input').keyup(function() { $('span').html($(this).val()); }); 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.