简体   繁体   中英

jQuery qTip 2 open only the required qTip on focus

I got many qtips in a form with lets like this :

$('.selector').qtip({
   content: {
      text: function(api) {
         // Retrieve content from custom attribute of the $('.selector') elements.
         return $(this).attr('qtip-content');
      }
   }
});

I dont want to add all qtips separately as it will create many javascript events which i dont like to do.

I got my html something like this i think it will make easy to answer my question:

<tr>
    <td>
    Main Alliase/Current Alliase:
    </td>
    <td><input type="text" id="maina"/>
    </td>
        <td id="handle-1" qtip-content="ToolTip's content here" class="selector">?</td>
    <td><div id="error-1" class="errors"></div></td>
    </tr>

Now what i want is that when i focus into the #maina it it changes the state of the qtip corresponding class selector .

But when i use this :

$('.selector').qtip('toggle', true);

this as of course toogles every tooltip related to it

How can i achieve my aim ?

This might help:

$("#maina").bind("focus", function () {
    $(this).closest("tr").find(".selector").qtip('toggle', true);
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM