Html – Get the value in an input text box

htmlhtml-inputjqueryjquery-selectorstextinput

What are the ways to get and render an input value using jQuery?

Here is one:

$(document).ready(function() {
  $("#txt_name").keyup(function() {
    alert($(this).val());
  });
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.4.3/jquery.min.js"></script>
<input type="text" id="txt_name" />

Best Solution

//Get
var bla = $('#txt_name').val();

//Set
$('#txt_name').val(bla);