I’m using this: http://docs.jquery.com/UI/Autocomplete
I’m initializing a text box like this (partial code):
$('#foo').autocomplete
{
source: function()
{
// How to get the id of the element?
}
}
In the source callback, I need to know what the id is of the current element. In this example, it’s obviously foo; in the real application, the selector is dynamically assigned so I don’t know what the id is.
I looked at the following:
console.debug($(this)); // displays [a.widget.a]
console.debug($(this.id)); // displays []
console.debug($(this).attr('id')); // displays undefined
How to get the id of the element?
Rather than assigning variables names to all the inputs you want
autocompleteon, you can use: