Tanoru Posted January 12, 2011 Share Posted January 12, 2011 Hi guys I'm trying to change the margin of an element after another has loaded. It does change the margin but then I can do nothing else with the page. No other JS functions work, nor do any links. Why is that? Here is the function: function pageHeight() { pageHeight = document.getElementById('header').clientHeight; $('#page p:first').css({'margin-top':pageHeight + 10}) }; $('#page').ready(function() {pageHeight()}) Link to comment Share on other sites More sharing options...
0 jackwanders Posted January 12, 2011 Share Posted January 12, 2011 I haven't tested it, but try: $('#page').ready(function(){ height = $('#header').height(); $('p:first',this).css('marginTop',(height+10)+'px'); } It sounds like your page might be locking up due to some wonky javascript. When that happens to me, I try to simplify the code as much as possible to reduce the possibility of errors. Link to comment Share on other sites More sharing options...
0 Tanoru Posted January 12, 2011 Author Share Posted January 12, 2011 That works thank you. I'll take that advice onboard. Javascript seems to be bitchy. Link to comment Share on other sites More sharing options...
Question
Tanoru
Hi guys I'm trying to change the margin of an element after another has loaded. It does change the margin but then I can do nothing else with the page. No other JS functions work, nor do any links. Why is that?
Here is the function:
function pageHeight() { pageHeight = document.getElementById('header').clientHeight; $('#page p:first').css({'margin-top':pageHeight + 10}) }; $('#page').ready(function() {pageHeight()})Link to comment
Share on other sites
2 answers to this question
Recommended Posts