I have a form with many inputs, all of them with the class “field”. On my JavaScript file, I have something like this:
$(".field").autocomplete({
source:"search.php",
select:function(event,ui){$(???).doStuff();}
});
What I need is some way to refer to the input field where the user is writing (that is, some selector in place of the “???”), so that I can do some stuff with the surrounding elements. I am guessing that the answer is something like “ui.field”, “ui.input” or “ui.element”, but I tried those and others with no luck, and I couldn’t find the answer in the documentation nor here, so I turn to you. Thanks!
It’s
this(that’s the raw element, not wrapped), as with most jQuery events. This could be documented better. 🙂 So in your case:Example (live copy):
HTML:
JavaScript: