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

Saturday, June 20, 2015

#deepstutorials: how to get the value of a textarea in jquery?


The following code creates a form with a textarea

<html>
<body>
<form action="demo_form.asp">
<textarea rows="4" cols="50" id= "comment" name="comment">
Enter text here...</textarea>
<input type="submit">
</form>
</body>
</html>
 


To access textarea using jquery ,following is the way
var message = $('comment').val();