I have the following input element on the page:
Search: <input id="example" />
I would like to capture the information the user enters in this box, when the user hits enter and display it on screen:
$(window).keypress(function(e) {
if(e.keyCode == 13) {
$("input[name=example]").val().insertAfter('#example');
}
The following results in an undefined:
$("input[name=example]").val() is undefined
How do you capture user inputed text?
You don’t have a
name.Use the
#selector:$('#example')