简体   繁体   English

标题为空时如何禁用cluetip?

[英]How to disable cluetip when title is empty?

The cluetip is displaying an empty "div" if title is empty. 如果标题为空,则cluetip显示空的“div”。 How to disable the cluetip when title is empty? 标题为空时如何禁用cluetip?

jQuery: jQuery的:

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

Html: 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. 当标题出现时,cluetip正确显示。 But when title is empty the cluetip should not be displayed(currently displaying an empty div). 但是当标题为空时,不应显示cluetip(当前显示空div)。 How to do it? 怎么做?

Simply bind to anchors which have a title (or a non-empty one): 只需绑定到具有标题(或非空标题)的锚点:

   // with title attribute present
   $('a[title].myClass').cluetip({
        splitTitle: '|',
        showTitle: false,                
        width: 400,
        tracking:true
    });

   // with an non-empty title
   $('a[title!=""].myClass').cluetip({
        splitTitle: '|',
        showTitle: false,                
        width: 400,
        tracking:true
    });

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/ http://jsfiddle.net/a9ECE/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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