Reputation: 736
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.
Upvotes: 8
Views: 3103
Reputation: 1620
$("#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");
Upvotes: 9
Reputation: 2042
use this $('select#elementID').attr('data-rel');
if it gives you the value "chosen" then the select
element is under chosen plugin.
Upvotes: 0