Thomas Ptrr
Thomas Ptrr

Reputation: 3

Output doesn't appear in Input field but value exists

I am confused, I used jQuery to $("#display").html(value) toward my html input with id ="display" but nothing appears in the html input.

However we can see the value in the element : "32" (see picture)

Any idea why the value doesn't appear?

I try to replace input by span and it works well.

image : example thanks,

Thomas

Upvotes: 0

Views: 241

Answers (1)

Jake
Jake

Reputation: 4234

You cannot set the innerHTML value of an input element (which is what jQuery is doing when you use $.html()). Instead, you need to use $.val().

Try using $("#display").val(value) instead.

Upvotes: 3

Related Questions