<input type="text" id="name" />
<span id="display"></span>
So that when user enter something inside "#name",will show it in "#display"
To get the textbox value, you can use the jQuery val() function. For example, $('input:textbox'). val() – Get textbox value.
jQuery val() Method The val() method returns or sets the value attribute of the selected elements. When used to return value: This method returns the value of the value attribute of the FIRST matched element.
Answer: Use the jQuery val() Method You can simply use the jQuery val() method to get the value in an input text box. Try out the following example by entering something in the text input box and then click the "Show Value" button, it will display the result in an alert dialog box.
You could simply set input value to the inner text
or html
of the #display element, on the keyup
event:
$('#name').keyup(function () {
$('#display').text($(this).val());
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With