Sagar Shah
Sagar Shah

Reputation: 19

javascript object reference not working by getElementById

When i change

$('#textarea').textcomplete([{

    //irrelevant code here

}]);

to

textarea.textcomplete([{

     //irrelevant code here
}]);

,it doesnt work. am i doing something wrong here?

jsfiddle: http://jsfiddle.net/tnzj2nfu/4/

I am using jquery.textcomplete.min.js plugin

Upvotes: 1

Views: 67

Answers (1)

Arun P Johny
Arun P Johny

Reputation: 388436

Because textarea is a dom element reference, and the textcomplete is a jQuery plugin which can be invoked using a jQuery object reference only.

Also there is no need to use getElementById() if you have jQuery, you can just use the id selector to get the element reference.

If you have a dom element reference, you can pass that to jQuery to get a jQuery reference

$(textarea).textcomplete([{...})

Upvotes: 1

Related Questions