Using jQuery to filter for specific nested unordered lists

dwlamb

Doing a tutorial on jQuery I am trying to subtly change a lesson to challenge myself but not having much luck. I've recreated a working prototype here http://jsfiddle.net/dwlamb/gph6b/

When run initially, the definition detail ("Monday to Friday 9-5") is displayed. All other definition details are hidden until the mouse enters another definition list item. This is achieved with the filter on dd in the first line of the jQuery.

How did I achieve the same initial appearance in this example: http://jsfiddle.net/dwlamb/DjR9b/ ?

I am want to hide the store hours for Stores B and C on the initial run and (eventually) program it so that when the mouse enters another first level list item (Store ? Hours) only those hours will be visible. I can not find a way to drill down and filter the second and third occurrences of ul below a parent ul

Jason Aller

If you change your:

$('ul ul').filter(':nth-child(n+3)').addClass('hide');

to:

$('ul ul').filter(':gt(0)').addClass('hide');

It will hide all second level unordered lists except the first one. It does this by taking the set of all nested unordered lists and filtering them so that only ones greater than (.gt()) are retained in the active selection.

This could even be shortened to:

$('ul ul:gt(0)').addClass('hide');

Where the filtering is being done as part of the selection rather than as a second separate step.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Adding a checkbox to an unordered list using JQuery

From Dev

Using jQuery to find list items containing specific text in nested lists

From Dev

Is it possible to index nested lists using tuples in python?

From Dev

Appending specific integers to nested lists - Python

From Dev

Using for loops and nested lists in python

From Dev

Twin unordered lists

From Dev

Python: Creating nested lists of floats using a for loop

From Dev

Filter file lists to get specific type files

From Dev

jQuery sortable and nested lists

From Dev

How to find specific object in nested lists?

From Dev

Jquery moving LI elements between unordered lists

From Dev

Create nested array from unordered lists in files

From Dev

Adding a checkbox to an unordered list using JQuery

From Dev

jQuery accordion for multiple nested lists

From Dev

Filter nested JSON based on specific value

From Dev

how to filter using jquery

From Dev

jQuery show only 5 list items of multiple unordered lists

From Dev

Linked lists using nested classes?

From Dev

Retrieving specific entries in Nested Lists

From Dev

Using count in mongodb while iterating nested lists

From Dev

Filter nested div's with jquery

From Dev

Using for loops and nested lists in python

From Dev

Filter through nested JSON object and obtain JSON with specific keys, using Ruby

From Dev

Adding Specific Value to Nested Lists

From Dev

Data on site not showing after clicking on sub menu on nested unordered list using ajax with jquery

From Dev

Binding unordered lists in prolog

From Dev

Javascript using .filter on nested arrays

From Dev

Unordered lists within ordered lists

From Dev

Creating Pandas dataframe from nested unordered html lists

Related Related

HotTag

Archive