How to update var self = this?

0 like 0 dislike
3 views
var function = function() { var self = this; $('#input').on('change', function() { var itemName = self.itemName; console.log(self.itemName); // old value }) }


As with every change in input to take actual self, because outside of the function this.ItemName changes.
by | 3 views

1 Answer

0 like 0 dislike
Why this hellish design?
here:
$('#input').on('change', function() { var inp_val = $(this).val(); console.log(inp_val); })
by
110,608 questions
257,186 answers
0 comments
33,907 users