こんにちは私はこのスクリプトhttp://jsbin.com/ipajo5/を稼働させようとしていますが、htmlテーブルがその場に配置されているので.each()の代わりに.live()each()の代わりにjquery live()を実装する方法
$(document).ready(function() {
$('.bi').each(function() {
// options
var distance = 10;
var time = 250;
var hideDelay = 500;
var hideDelayTimer = null;
var beingShown = false;
var shown = false;
var trigger = $('.tt', this);
var popup = $('.popup', this).css('opacity', 0);
// set the mouseover and mouseout on both element
$([trigger.get(0), popup.get(0)]).mouseover(function() {
if (hideDelayTimer) clearTimeout(hideDelayTimer);
if (beingShown || shown) {
return;
} else {
beingShown = true;
popup.css({
top: $(this).position().top-150,
left: $(this).position().left-100,
display: 'block'
})
.animate({
top: '-=' + distance + 'px',
opacity: 1
}, time, 'swing', function() {
beingShown = false;
shown = true;
});
}
}).mouseout(function() {
if (hideDelayTimer) clearTimeout(hideDelayTimer);
hideDelayTimer = setTimeout(function() {
hideDelayTimer = null;
popup.animate({
top: '-=' + distance + 'px',
opacity: 0
}, time, 'swing', function() {
shown = false;
popup.css('display', 'none');
});
}, hideDelay);
});
});
});
注意。いくつかのスレッドでは、パフォーマンスのためにlive()の代わりにdelegate()を使用することを推奨していますが、何日もの後、私はこのポップアップ/ツールチップを動作させたいだけです。
ありがとうございます。
私はそれを関数に変換し、描画関数の最後に追加しました(私は、ページ上に2つのテーブルが異なって動作します)。私は後でmouseenterとmouseleaveを試し、異なるブラウザでより多くのテストを行い、ページのすべての機能を完了します。ありがとう@ダニエル –