Assuming .each()there won't be much performance when using , I would do something like this:
jQuery('#img').children().each(function(i,obj){
if (i <= 0) {
if (i >= $('#img').children().length - 1) {
});
Then hide everything $('#img').children()except the active, or else you want it to function.
source
share