Skip to main content

JQuery onclick assign val from txt to txt

<!DOCTYPE html>
<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
<script>
$(document).ready(function(){
    $("#btn").click(function(){
        $("#t").val($("#tc").val());
    });
});
</script>
</head>
<body>

<p>Name: <input type="text" id="tc" value="Raj"></p>

<button id="btn" >Show Value</button>
<br><br>
<input type="text" id="t">
</body>
</html>

Comments