Krishna Mohan
Krishna Mohan

Reputation: 315

unable to assign text box value to another text box in jquery

i want to display one text box value in another text box while clicking button. im able to show value on div but not in text box

Here is the JS

$(document).ready(function(){

$("#btnSubmit").click(function(){


 var val= $("#txtValue").val();
$("#txtValue1").text(val);
$("#myDiv").text(val);
})
});

Here is the HTML

<input type="text" id="txtValue">

<div id="myDiv"></div>
<input type = "button" id = "btnSubmit" value="Submit">
<input type="text" id="txtValue1" text="">

Upvotes: 1

Views: 569

Answers (1)

Cory
Cory

Reputation: 1283

For an input type='text' you need:

 $("#txtValue1").val(val);

It is an input; inputs take values

Demo

Upvotes: 3

Related Questions