简体   繁体   中英

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?

I want to make some actions if for example select element is under Chosen plugin.

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

This will return the chosen object assigned to the element, or undefined if not assigned.

Note: For other plugins or JQuery versions I worked with, you may need to check the plugin name suffixed with "Obj":

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

use this $('select#elementID').attr('data-rel');
if it gives you the value "chosen" then the select element is under chosen plugin.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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