[英]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();
几天前,我有一个关于使用一个名为 select2 的库的问题,在其安装和使用的官方文档中,您必须通过 jquery
$('.mySelect').select2();
获取元素。 my doubt is what it does exactly when you do this action .select2();
我怀疑当您执行此操作时它到底做了什么
.select2();
(in a technical way) to the element and what would be the equivalent action doing it with document.getElementById('mySelect')
. (以技术方式)对元素以及使用
document.getElementById('mySelect')
执行的等效操作是什么。
It's a jQuery-Plugin
.这是一个
jQuery-Plugin
。 Underlying there is a function which has a reference to your selected element ( .mySelect
) in the this
statement.底层有一个 function ,它在
this
语句中引用了您选择的元素 ( .mySelect
)。 Take a look here for more information https://learn.jquery.com/plugins/basic-plugin-creation/在这里查看更多信息https://learn.jquery.com/plugins/basic-plugin-creation/
Select2 is based on Jquery, can't use Select2 without Jquery. Select2 基于 Jquery,没有 Jquery 不能使用 Select2。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.