The Code:
var cycler = function(parentContainer){ var listContainer = $(parentContainer); var firstPost = $(parentContainer + " li:first"); cycle = function(){ removeFirst(); } removeFirst = function(){ firstPost.fadeOut(appendToEnd); }; appendToEnd = function(post){ firstPost.remove(); listContainer.append(firstPost); firstPost.fadeIn(); }; return{ cycle : cycle } }; $(function(){ $("#btnCycler").click(function(){ var listCycler = new cycler("#posts"); listCycler.cycle(); }); });The HTML:
JS Demo
- First text
- Second text
- Thrid
- Fourth Text
No hay comentarios:
Publicar un comentario