March 25, 2012

How to check if selector has qtip?

Question by rjmcb

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

For example

$('input').qtip("hasqtip");

Answer by Starx

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 
   }
});

Author: Nabin Nepal (Starx)

Hello, I am Nabin Nepal and you can call me Starx. This is my blog where write about my life and my involvements. I am a Software Developer, A Cyclist and a Realist. I hope you will find my blog interesting. Follow me on Google+

...

Please fill the form - I will response as fast as I can!