2

テストテキストを失うことなく、またクローンを作成せずに、方向を「n」から「w」に変更するにはどうすればよいですか?

$(".tipsy").live('mouseover',function() {
    $(this).tipsy({gravity: "n", html: true});
    $(this).tipsy("show");
});

$(".tipsy").live("click",function() {
    $('.tipsy').remove();
    $(this).tipsy({gravity: 'w', html: true});
    $(this).tipsy("show");
});

<div class="tipsy" title='<u>test link</u>'>TestTestTestTestTestTestTestTestTestTestTest</div>

これがフィドルです:http://jsfiddle.net/nQvmw/23/

4

1 に答える 1

2

見られるようにほろ酔いプラグインのホームページでは、重力オプションとして方向を返す関数を渡すことができます。

$(el).tipsy({gravity: function(){return Math.random()>.5 ? 'w' : 'n';}

この機能に基づいて、さまざまなマウスアクション(マウス入力、クリック...)に対してさまざまな方向を返す関数を簡単に作成できます。

var flag = false;
function gravity(){
    return flag ? 'n' : 'w';
};

$(".tipsy")
    .live('mouseover',function(){
        flag = true;
        $(this).tipsy("show");
    })
    .live("click",function() {
        flag = false;
        $(this).tipsy("show");
    })
    .tipsy({
        gravity: gravity,
        html: true
    });

これが実際のデモです

于 2012-03-30T15:22:31.150 に答える