coool
coool

Reputation: 8297

jquery :input text how to get

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

Upvotes: 3

Views: 7475

Answers (1)

chaos
chaos

Reputation: 124325

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

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

Upvotes: 7

Related Questions