What happens when we bind an element in jQuery? -


I used the key_1 to bind one function to an input element text_1 . Somehow the value of the text field is found by $ (this) .val () .

I tried to understand this , but the best description "always" refers to the "owner" of the function that we execute. What is the "owner" in this case? How does $ (this) .val () become the value of the field? Keys What happens when

I am a newb in javascript and jquery.

  function text_1 () {var val = $ (this) .val (), html = 'The rejected AJAX request has not been rejected:' + text_counter_1 +++ 'bar. + (Val? 'Text:' + val: ''); $ ('#text-type-1'). Html (html); }; $ ('Input.text'). Keyword (text1);  

"This" is set based on the current context and scope. JQuery will set the "this" element to trigger this event. In this case, the jQuery HTML element (Input) will point to "this" which will set the key up event firing.

By $ (this) - You are wrapping an HTML object, currently set to it, with a JQuery object and thus you can call .val () on your search input.


Comments