Skip to content

Instantly share code, notes, and snippets.

@omniosi
Created February 13, 2014 17:12
Show Gist options
  • Select an option

  • Save omniosi/8979389 to your computer and use it in GitHub Desktop.

Select an option

Save omniosi/8979389 to your computer and use it in GitHub Desktop.
function to reveal more
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
<ul>
<li>One</li>
<li>Two</li>
<li>Three</li>
<li>Four</li>
<li>Five</li>
<li>Six</li>
<li>Seven</li>
<li>Eight</li>
<li>Nine</li>
<li>Ten</li>
<li class="more">More</li>
</ul>
</body>
</html>
$(document).ready(function(){
var ul = $('ul'),
//li = $('li'),
more = $('.more'),
list = $(ul).children().length;
more.hide();
console.log(list);
if( more.is(':hidden') ){
if(list > 3){
$("li:gt(2)").hide();
more.show();
}
}
more.on('click',function(){
$("li:gt(2)").show();
more.hide();
});
});
@omniosi
Copy link
Author

omniosi commented Feb 13, 2014

Updated show more function

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment