tags:

views:

26

answers:

1

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 document 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....

+2  A: 

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)
});
Damien