jQuery Form How to - Get the value from input element








Question

We would like to know how to get the value from input element.

Answer


<!-- w ww  .  ja va  2  s.  c o  m-->
<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'
  src='http://code.jquery.com/jquery-1.8.3.js'></script>
<script type='text/javascript'>
$(window).load(function(){
    $(function(){
         $buttonObject = $("#buttonobj");
         $buttonObject.prop('disabled', true);
         console.log($buttonObject.val());
    });
});
</script>
</head>
<body>
  <input type="button" id="buttonobj" class="some class"
    value=" Button Name" />
</body>
</html>

The code above is rendered as follows: