Hide list items (only show 3)

by ashleycam3ron

HTML

<ul id="mylist">
    <li>List 1</li>
    <li>List 2</li>
    <li>List 3</li>
    <li>List 4</li>
    <li>List 5</li>
</ul>

JavaScript

// hide all li and then show the first two
$('ul li').hide().filter(':lt(3)').show();