Aaron Walker
Aaron Walker

Reputation: 195

How to "tap" a list item within a list item?

The purpose of the code is a menu dropdown.

The dropdown menu works in a normal browser on a desktop. However, items[1].children('a') is not calling the function.

Here is the important part:

if ($('body').hasClass('mobile')) {
    $(items[0].children('a'), items[1].children('a')).each(function() {
        $(this).on('vclick', function(e) {
            var menu = $(this).parent();

Here is the full code:

http://jsfiddle.net/G6w9M/

Upvotes: 0

Views: 134

Answers (1)

Gabriele Petrioli
Gabriele Petrioli

Reputation: 196236

You seem to want to combine the two elements with this line

 $(items[0].children('a'), items[1].children('a'))

but you are not. (see http://api.jquery.com/jquery/#jQuery1)

You are using the second as the context in which to search for the first..

Use an array to combine them or the .add() method

$([items[0].children('a'), items[1].children('a')])

or

$(items[0].children('a')).add(items[1].children('a'))

Upvotes: 1

Related Questions