I need a function to run when a divs data-page-index attribute changes
var active = $('.swipeview-active'),
dpi = parseInt(active.attr('data-page-index')),
left = $('[data-page-index="' +prev+ '"]').children("img").eq(0),
right = $('[data-page-index="' +next+ '"]').children("img").eq(0);
$(active.attr('data-page-index')).change(function(){
right.clone( true ). css({'z-index': 5}). fadeIn(2000).appendTo('#right');
left.clone( true ). css({'z-index': 5}). fadeIn(2000).appendTo('#left');
});
I tried the change() function but that only seems to work with input fields,
$(active.attr('data-page-index')).change(function(){
is there another way of achieving this? Thanks.