Wednesday, February 27, 2013

jQuery to show only first element in a group

In this post, find jQuery code to show only first element within a group or container or div element. You must have seen this feature on Facebook. If you have not seen, then go to Facebook -> Photos -> Click on Album tab. Take mouse on any album, and you will find other images are getting previewed. But the point is, when the page was loaded only first item was visible and rest were hidden.

Related Post:

To show only first image within div where multiple images are placed.
$("div.List").each(function () {
   $("img :not(:first)", this).hide();
});
If you have placed any list (ul->li) element, then you can use below code to hide other items.
$("div.List").each(function () {
   $("ul li:not(:first)", this).hide();
});
Feel free to contact me for any help related to jQuery, I will gladly help you.