How to check if qtip selector has?

How to check if an item is created using the qtip plugin?

for instance

$('input').qtip("hasqtip"); 
+6
source share
3 answers

A very simple way is to apply the plugin using the class selector, for example, in anchors

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

Then, to check if qtip has a link to 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 } }); 
+8
source

The authors proposed a way to check for qtip on an element in order to use the following method:

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

Demo

+11
source

Another way to do it

 if($("#mybtn").attr("data-hasqtip")) { $("#mybtn").qtip().destroy(); } 

The qtip2 element will have the data-hasqtip attribute. If an attribute has never been created or destroyed, will be absent

eg.

 <button id="mybtn" class="infobtn" style="float: left; display: block;" data-hasqtip="2"> <i class="fa fa-info-circle fa-lg"></i> </button> 
0
source

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


All Articles