jQuery debounce, way to pass the element along to the function? -
html
<input class="list_item_title mini" name="list_item[title]" size="30" type="text" value="what happens when user creates new item?">
js:
function text_2(e) { console.log(e.val()); }; $(function() { $('input.list_item_title').keyup( $.debounce( 250, text_2 ) ); });
e.val() doesn't work. how can pass input along can value?
thanks
e
reference event object [docs], not input
element.
you can reference input
element using event.currenttarget
[docs].
after having @ source code, should able access element this
(like in other event handler), following should work:
function text_2(e) { console.log($(this).val()); };
Comments
Post a Comment