I want to change the position of div according to offset ie top, bottom, left, right is it possible ? i have tried some jquery but it is not working
$(document).ready(function(){
var offset = $("#myPopup").offset();
$('#popup').css('left',offset.left);
$('#popup').css('top',offset.top);
});
<div id="myPopup"> popup</div>
I am guessing that you did not use a position type in your style. I've put it in your jQuery for easy test, but you better put that in a css...
$(document).ready(function(){
var offset = $("#myPopup").offset();
$('#popup').css('position','relative');//or absolute.
$('#popup').css('left',offset.left);
$('#popup').css('top',offset.top);
});
<div id="myPopup"> popup</div>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.