javiershaka
javiershaka

Reputation: 149

How can I apply a jQuery plugin to a JavaScript DOM element?

A couple of days ago I had a question about the use of a library called select2, that in the official documentation for its installation and use you have to obtain the element through jquery $('.mySelect').select2(); my doubt is what it does exactly when you do this action .select2();(in a technical way) to the element and what would be the equivalent action doing it with document.getElementById('mySelect').

Upvotes: 0

Views: 45

Answers (2)

J. Doe
J. Doe

Reputation: 867

It's a jQuery-Plugin. Underlying there is a function which has a reference to your selected element (.mySelect) in the this statement. Take a look here for more information https://learn.jquery.com/plugins/basic-plugin-creation/

Upvotes: 1

Rajen Trivedi
Rajen Trivedi

Reputation: 1302

Select2 is based on Jquery, can't use Select2 without Jquery.

Read More About this issue

Upvotes: 0

Related Questions