简体   繁体   English

如何识别在元素上初始化的Chosen插件

[英]How to identify that Chosen plugin initialized on element

Is there a standard way to know that jQuery plugin already initialized at specific HTML element? 有没有一种标准方法可以知道jQuery插件已经在特定的HTML元素中初始化了?

I want to make some actions if for example select element is under Chosen plugin. 我想做一些动作,例如select元素在Chosen插件下。

$("#elementId").data("chosen");

This will return the chosen object assigned to the element, or undefined if not assigned. 这将返回分配给元素的所选对象,如果未分配则返回undefined。

Note: For other plugins or JQuery versions I worked with, you may need to check the plugin name suffixed with "Obj": 注意:对于我使用过的其他插件或JQuery版本,您可能需要检查后缀为“Obj”的插件名称:

$("#elementId").data("pluginNameObj");

use this $('select#elementID').attr('data-rel'); 使用这个$('select#elementID').attr('data-rel');
if it gives you the value "chosen" then the select element is under chosen plugin. 如果它给你“选择”的值,那么select元素在选择的插件下。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM