Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to check if selector has qtip?

How can I check if an element is instantiated with a qtip plugin?

For example

$('input').qtip("hasqtip");
like image 550
rjmcb Avatar asked Mar 25 '12 06:03

rjmcb


2 Answers

The authors suggested way to check for existence of qtip on an element is to use the following method:

if( 'object' === typeof $(elem).data('qtip') )

Demo

like image 164
Baz1nga Avatar answered Oct 18 '22 11:10

Baz1nga


An very easy way would be to apply the plugin using a class selector like, in anchors

$("a.qtip").qtip(); //Apply qtip, to only those links with qtip class on them

Then, to check if a link has qtip on them, check their class

$('a').click(function() { //whenever a link is cliked
   if($(this).hasClass('qtip')) { //check if it has qtip class on them
     //if it has

     //SCREAM: yes i found a qtip :D 
   }
});
like image 20
Starx Avatar answered Oct 18 '22 11:10

Starx