0

当我将鼠标悬停在类中的元素上时,我想显示 poshytips,但前提是它们满足内容函数中指定的条件。如果没有,我不希望出现一个空气泡。

$('[class~="label"]').poshytip({
            slide: false, 
            followCursor: true, 
            alignTo: 'cursor', 
            showTimeout: 0, 
            hideTimeout: 0, 
            alignX: 'center', 
            alignY: 'inner-bottom', 
            className: 'tip-ihme',
            offsetY: 10,
            content: function() {
                if(this.id.length>25 & sbar.settings.stackBy == 'region') {
                    return this.id
                }   
            },
            liveEvents: true
        });
    }

但是,当我将鼠标悬停在不符合此规范的元素上时(即 this.id.length<25),仍然会显示一个小(空)气泡。有没有办法过滤掉 jquery 调用中的选择?我尝试了数组样式过滤:

  $('[class~="label"]').filter(function(d) { return d.id.length>25}).poshytip(....

谢谢,

4

1 回答 1

1

试试这个:

$('[class~="label"]').each(function(){
    if($(this).attr('id').length>25)
    {
        $(this).poshytip({
           // your code
        });
    }
});
于 2013-02-28T07:28:23.817 回答