I want to be able to have a javascript function that hides divs for me. For example, I have something like
<div id='container'>
<div class='item'></div>
<div class='item'></div>
<div class='item'></div>
<div class='item'></div>
<div class='item'></div>
</div>
And i would like the function to hide every ‘item’ class element after say the first 3. How would i go about this?
Thanks for any help
In JS, you could do something like this, provided the item divs are the only children of the container div:
Try it here: http://jsfiddle.net/eY9ZD/
Otherwise, you could do this:
Try it here: http://jsfiddle.net/6TcWE/
And finally, if jQuery is an option, there’s a one-liner using the
gtselector:Try it here: http://jsfiddle.net/J8wK6/