How to determine that the selected plugin is initialized on an element

Is there a standard way to find out if a plugin is jQueryalready initialized in a specific HTML element?

I want to do some action if, for example, the item selectis in the Chosen section.

+4
source share
2 answers
$("#elementId").data("chosen");

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

Note. For other plugins or versions of jQuery I've worked with, you may need to check the plugin name with "Obj":

$("#elementId").data("pluginNameObj");
+3
source

$('select#elementID').attr('data-rel');
, "", select .

0

Source: https://habr.com/ru/post/1583950/


All Articles