EN
                                
                            
                        jQuery - get value of input field
                                    12
                                    points
                                
                                In this article, we would like to show you how to set input field value using jQuery.
Short solution
var value = $('#my-input').val();
var value = $('#my-input').attr('value');
1. Input val method example
// ONLINE-RUNNER:browser;
<!doctype html>
<html>
<head>
  <style>  
  
    input {
    	padding: 10px;
      	width: 300px;
    }
    
  </style>
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.0.0/jquery.min.js"></script>
</head>
<body>
  <input id="my-input" type="text" value="This is example value..." />
  <script>
    var input = $('#my-input');
    var value = input.val();
    console.log(value);
  </script>
</body>
</html>
2. Input attr method example
// ONLINE-RUNNER:browser;
<!doctype html>
<html>
<head>
  <style>  
  
    input {
    	padding: 10px;
      	width: 300px;
    }
    
  </style>
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.0.0/jquery.min.js"></script>
</head>
<body>
  <input id="my-input" type="text" value="This is example value..." />
  <script>
    var input = $('#my-input');
    var value = input.attr('value');
    
    console.log(value);
  </script>
</body>
</html>