Search code examples
jquerycluetip

How to disable cluetip when title is empty?


The cluetip is displaying an empty "div" if title is empty. How to disable the cluetip when title is empty?

jQuery:

$(document).ready(function () {
        $('a.myClass').cluetip({
            splitTitle: '|',
            showTitle: false,                
            width: 400,
            tracking:true
        });
    });

Html:

<a class="myClass" title="" >Sample Text</a>
<a class="myClass" title="Samle Title" >Sample Text2</a>

When title is present the cluetip is displaying correctly. But when title is empty the cluetip should not be displayed(currently displaying an empty div). How to do it?


Solution

  • Filter out the anchors with no title or empty title using the filter function

    $('a.myClass').filter(function() {
        return this.title !== '';
    })​.cluetip({
        splitTitle: '|',
        showTitle: false,                
        width: 400,
        tracking:true
    });
    

    http://jsfiddle.net/a9ECE/