I'm trying to perform the very simple task of selecting all of the section
s in my DOM using jQuery, but for some reason $sections
is null everytime I do the following:
HTML:
<div class="container">
<div id="bl-main">
<section>
...
</section>
<section>
...
</section>
</div>
</div>
<script>
$(function() {
Boxlayout.init();
});
</script>
Javascript:
var Boxlayout = (function() {
var $el = $( "#bl-main" );
var $sections = $el.children("section");
...
// init function and more code down below
});
Does anybody see what I'm doing wrong?
Edit: I'm working on this project in Rails, so it's very likely that I've messed up some part of Rails. The HTML is located in app/assets/views/static_pages.html.erb
, and the JS is located in app/assets/javascripts/static_pages.js