reub77
reub77

Reputation: 1289

jQuery Click event not working for jCarousel

The title to this question is partially true. The click events work for the three initial carousel items i display on load. Once you click previous or next the new items don't trigger the click event and neither do any of the 3 original items if they get moved off the screen.

I'm using the latest version of jquery and am displaying 3 items by default. My objective is to be able to access text inside each carousel item that is contained in an anchor tag. Each carousel item has an image, and an anchor tag surrounding a title.

$('li').click(function() { 
    var clickedItem = $(this).attr('class');
    console.log(clickedItem);
});

If i can get this simple click event to occur on the other elements all will be good. Any ideas?

Upvotes: 1

Views: 3471

Answers (1)

karim79
karim79

Reputation: 342645

Try this:

$("#carousel").delegate("li", "click", function() {
    var clickedItem = $(this).attr('class'); 
    console.log(clickedItem);
});

Upvotes: 1

Related Questions