0

I'm experiencing a kind of specific issue which I'm hoping can be generalized.

I'm trying to use jQuery to alter a div with id="footer-wrapper" that I know exists.

When trying to do this from within a node in Drupal, jQuery can't seem to find the element:

<script type="text/javascript">
    alert("div with id=\"page\" has length: " + ($("#page").length));
    alert("div with id=\"footer-wrapper\" has length: " + ($("#footer-wrapper").length));
</script>

However it can find the div with id="page", which is also outside the node body. I don't understand why it would be able to find one and not the other.

Here is a rather messy fiddle and here is a link to the actual page.

dougmacklin
  • 2,560
  • 10
  • 42
  • 69

1 Answers1

2

It is probably being called before the footer is loaded. Have you tried wrapping it with:

$(document).ready(function({
     [alert statements]
});
eomer
  • 397
  • 1
  • 3
  • 14
  • hmmm i've been using head.ready() from head.js because I was under the impression it encompassed $(document).ready() because of [an answer to a another question](http://stackoverflow.com/questions/12221122/head-ready-vs-document-ready). I guess not :/ – dougmacklin Dec 12 '12 at 22:06