$(document).ready(function() {
//select all the a tag with name equal to modal
$('a[name=popup]').click(function(e) {
//Cancel the link behavior
e.preventDefault();
//Get the A tag
var id = $(this).attr('href');
//Set the popup window to center
$(id).css('top', winH/2-$(id).height()/2);
$(id).css('left', winW/2-$(id).width()/2);
can i change the popup window below the a href tag(top:dom?+20px) and not center??
You can change your
topto this:.offset()returns the position of the clicked link, and you want thetopvalue, this returns the top of the clicked link, so you may want to add it’s height as well, e.g.: