This is driving me insane. At some point everything seemed to be working fine but suddenly everything stopped working and I have no idea why.
I have a set of divs with a class for which I want to hide everything but the first four divs.
<div id="container">
<div class="item">content 1</div>
<div class="item">content 2</div>
<div class="item">content 3</div>
<div class="item">content 4</div>
<div class="item">content 5</div>
</div>
And I have the following in the head of the doc
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script>
$(window).load(function() {
$(".item:gt(3)").hide();
});
</script>
Why doesn't this work?
I have to say the the ".item" divs load dynamically based on a variable that is set on the URL. Something like mydoamin.com/myitems/?zicode=10005
So the items displayed come from an external database and loaded in the page.
My assumption was that $(window).load waits for all those items to exist in the document. Am I wrong? and in that case, how can I make sure to execute a function only after everything is really loaded?