Hansi Zimmrer
Hansi Zimmrer

Reputation: 259

How to get the element of a jQuery object

I've got some autocomplete:

            $(".some_class").autocomplete({
                source: function(request,response){
                    //get input values and store into myArray
                    var element= $(this); //not working

.some_class is connected to input fields, which is what I actually want to have. I thought $(this) would return the the input field. Instead I'm getting this:

Object { element={...}, options={...}, menu={...}, mehr...}

How can I access the element? When I used it like that before, I had no problems accessing the element.

EDIT:

Actually I want the value of the name-attribute of the input-field. Do you have an Idea how to manage that?

Upvotes: 0

Views: 36

Answers (1)

Bill Criswell
Bill Criswell

Reputation: 32921

I believe you're looking for:

var element = this.element;

element is already a jQuery object.

Here is the demo I used for testing: http://jsfiddle.net/y7vT4/

Upvotes: 2

Related Questions