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 j开发者_如何学运维query 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?
Try this:
$("#carousel").delegate("li", "click", function() {
var clickedItem = $(this).attr('class');
console.log(clickedItem);
});
精彩评论