I have used keyup
to bind an input element to a function text_1
. The function somehow gets the value of the text field by $(this).val()
.
I tried to understand this
, but the best explanation is "this always refers to the “owner” of the function we're executing". What is the "owner" in this case? How does $(this).val()
become the value of the field? What gets passed when keyup
occurs?
I am a newb in Javascript and jQuery.
function text_1() {
var val = $(this).val(),
html = 'Not-debounced AJAX request executed: ' + text_counter_1++ + ' times.'
+ ( val ? ' Text: ' + val : '' );
$('#text-type-1').html( html );
};
$('input.text').keyup( text_1 );