tags:

views:

561

answers:

1

Hi,

I am trying to get the value of the text in the input fields. what is the best way to do it in jquery. I tried .text() it doesn't work.

`

<html>
  <head>
    <title></title>
    <script type="text/javascript" src="js/jquery.js"></script>

    <script type="text/javascript">


$(document).ready(function(){

   var t = $(":input").text();

   alert(t);
});



    </script>


    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
      <form name="f">
        <input type="text" name="t" value="cake">tes</input>

      </form>
  </body>
</html>

`

THnks Coool

+4  A: 

You want $(':input').val().

Your use of input as an enclosing tag is incorrect HTML and will not do anything useful, FYI.

chaos