jQuery autocomplete on class, how to get id

Try:

$(this.element).prop("id");

or:

this.element[0].id;

Inside of the source callback, this refers to the widget instance. In order to get the element the widget is attached to, you should use this.element, which is a jQuery object.


I tried it out in a project of mine. This worked for me:

$(this.element.get(0)).attr('id');

I was in a situation similar to you, user1572796 and this is what worked for me:

$(this).prop("id");