Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get the value in an input text box

What are the ways to get and render an input value using jQuery?

Here is one:

$(document).ready(function() {    $("#txt_name").keyup(function() {      alert($(this).val());    });  })
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/1.4.3/jquery.min.js"></script>  <input type="text" id="txt_name" />
like image 682
Bharanikumar Avatar asked Nov 03 '10 15:11

Bharanikumar


People also ask

How can I get the value entered in the input field?

Answer: Use the value Property You can simply use the value property of the DOM input element to get the value of text input field.

Which function is used to get value from the input textbox?

You can simply use the jQuery val() method to get the value in an input text box.

How do I get user input from a text box?

To extract the information which a user enters into the text fields using Javascript, the Javascript code to do would be: The line document. getElementById("firstname"). value accesses the text box with an id of firstname and retrieves the value which the user has entered into this text box.


1 Answers

//Get var bla = $('#txt_name').val();  //Set $('#txt_name').val(bla); 
like image 152
Conrad Avatar answered Sep 19 '22 11:09

Conrad