Pages

Sunday, June 21, 2015

#deepstutorials:How do I get the value of a textbox using jQuery

The following code creates a form with a textbox

 <html>
<body>
<form>
First name: <input type="text" name="FirstName" id="firstName"><br>
Last name: <input type="text" name="LastName" id="lastName"><br>
<input type="submit" value="Submit">
</form>
<body>
</html>

 To access textbox using jquery ,following is the way
var firstName= $('#firstName').val();  //
$("#firstName").val("someValue")//Is used to set the value of textbox

No comments:

Post a Comment