开发者

how can i auto align a div to <a> tag on document

i have a div i.e

<div id="data_sprite">Jquery ajax data here</div>

and it is invisible....

now suppose i have my first <a> tag on top of docu开发者_如何学Cment and 2nd <a> tag on bottom of document... now what i want is that if i click on <a> on top of page the div auto align with its top right corner and when i click on <a> at bottom the div should auto align with its top right corner how can i achieve that with jquery or what ever....


With JQuery, you can try something like that, assuming ajaxlink is a class used for both your tags:

$('.ajaxlink').click(function() {
  var position = $(this).offset();
  position.left = position.left + $(this).width() - $('#data_sprite').width();
  position.top = position.top + $(this).height();
  $('#data_sprite').css(position)
});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜