以下の HTML でjquery UI position API (#changer
に対して)を使用して div を配置しようとしています。.demo
<div class="demo-content">
<div class="demo" title="click anywhere inside" >demo div</div>
<div class="demo" title="click anywhere inside" >demo div</div>
<div class="demo" title="click anywhere inside" >demo div</div>
<div class="demo" title="click anywhere inside" >demo div</div>
</div>
<div id="changer">changer div</div>
JS:
$('.demo').click(function() {
var _that = this;
$("#changer").fadeOut(100, function() {
console.log(_that.className);
$(this).position({
of: _that,
my: 'left top',
at: 'right top',
offset: '10 10'
}).show();
});
});
ノート:
- 初めてでも問題なく動作します。
- 以下のようにコードを削除して外側
.fadeOut
に移動すると、同じことがうまくいきます.position
$("#changer").position({
of: this,
my: 'left top',
at: 'right top',
offset: '10 10'
}).show();
.hide
beforeを追加しても同じように失敗します.position
。((すなわち) $("#changer").hide().position
)
ここで何が間違っているのか知りたいです。