Andrei RRR
Andrei RRR

Reputation: 3162

jQuery Click not working on iScroll 4?

I have this bit of code which iScoll 4 displays correctly:

<ul id="thelist">
<li id="1">Option 1</li>
<li id="2">Option 2</li>
<li id="3">Option 3</li>
<li id="4">Option 4</li>
</ul>

but when I use this jQuery code it doesn't work:

$("li").click(function(){
alert($(this).text());
});

and the most curious part is that this bit of code works:

$("#thelist").click(function(){
alert($(this).text());
});

Someone can help me with this?

Upvotes: 2

Views: 815

Answers (2)

frenchie
frenchie

Reputation: 51997

There are several ways to write this; I'd try with .on() and see what happens:

$('#thelist').on({

    click: function () { alert($(this).text()); }

}, 'li');

Here's a jsfiddle to test with.

Upvotes: 2

Leigh Starrett
Leigh Starrett

Reputation: 21

Have you tried $("#thelist").children("li").click(function() { ...

Upvotes: 0

Related Questions