May 15, 2012
How to set top position using jquery
Question by Rajanikant Shukla
I am creating custom div scroller and want to set top position of content div. My jquery code is as bellow:-
containerOuterHeight=$("#messagePopUpContainer").outerHeight();
contentOuterHeight=$("#content").outerHeight();
contentTopPosition=$("#content").offset().top;
alert("contentTopPosition"+contentTopPosition);
alert(contentTopPosition-(containerOuterHeight/20));
$("#content").offset().top=contentTopPosition-(containerOuterHeight/20);
//$("#content").css("top",( contentTopPosition-(containerOuterHeight/20) ) + "px");
alert("contentTopPosition"+$("#content").offset().top);
//alert("Fontsize"+$('#content').css('font-size') );
and html is :-
<div id='messagePopUpContainer' style='background-color:#ffffff; overflow: hidden;'>
<a href='javascript:void(0);' id='popupanchor' onkeydown='PopupKeyHandler("' + elmId + '");'></a>
<div id='content' style='width:350px'>' + methods.settings[elmId].text + '</div >
<div id='popupReturn'>Return</div></div></div>'
can you suggest me how to do this. any help will be appriciated.
Thanks