• 0

[Javascript] Dynamically change margin


Question

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

  • 0

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

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.