I'm trying to get data from either the 'curr' or 'next' object available in jquery cycle's onBefore function so I can pass it to a PHP script with ajax to populate opts.addSlide();
Ideally i'd like to be use the data() attribute but i'm struggling even to use .attr()
In the documentation, this works:
var currentImageNum = parseInt(next.src.match(/beach(\d)/)[1]);
and i've seen this working
var tag = next.tagName.toLowerCase();
so why can't I use this or something similar
var mydata = next.attr('id');
to get the ID of the slide
the error I get is Uncaught TypeError: Object # has no method 'attr'
Since next
is a DOM element you should first convert it into jQuery object and then you can call jQuery apis on it. Try this
$(next).attr('id')