Index
Index

Reputation: 736

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.

Upvotes: 8

Views: 3103

Answers (2)

Javier Rey
Javier Rey

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

Theo
Theo

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

Related Questions