I have a jsFiddle up with an example to work from.
$().ready(function() {
$('.test').each(function() {
$this = $(this);
$this.data('Worker', function() {
$('#stop').html((parseInt($('#stop').html()) + 1))
})
setInterval($this.data('Worker'), 100);
});
$('#stop').click(function() {
// I want the worker function to stop being triggered here
$('.test').remove();
});
});
What I would like to do is attach a worker function to an element in the DOM so that when the element is removed, the worker function stops.
Is something like this possible?