I am working on a jQuery plugin that hides all the elements within a container and then shows them over a set interval using either fadeIn() or by jquery's animate function.
So far I've managed to get all the elements into an array and I can print out the html in an alert if i do
$(children).each(function (index, val) {
alert(this);
});
However, when i try to add the elements as html again to the document i get no luck.
I've tried
$(container).append(this);
and
$(container).appendChild(this);
but still no luck.
What i need ideally, is to be able to fadeIn() each element again and also add a css class to each element over a set interval.
(function($) {
$.fn.myPlugin = function (options) {
// Set default options
var defaults = {
rate : '1000',
}
var options = $.extend(defaults, options);
// Hide all elements within parent container
$(this).children().hide();
var container = $(this).selector;
// Store children in loader variable
var loader = $(this).children();
// Put all elements into an array
var children = [];
$(loader).each(function(idx) {
children.push(this.outerHTML);
});
// Iterate over array and fadeIn elements;
$(children).each(function (index, val) {
});
};
})(jQuery);
$(this).selectorsounds wrong to me, what does it do?