Create a live-update list effect with jQuery
Posted in jQuery, Tutorials by Gergely MartonI wrote this little tutorial because yesterday I’ve searched the web for 2 hours to find something similar, but nothing came up.
We were required to create a “live update” effect for a list in which new list items were added almost every 5 seconds.
The web page, where all this needed to function, is an auction page for clothing and shoes at Catman – Shopping Catalog.
Basically, whenever someone placed a higher bid then the last person in the list, it had to update to show the last bid first, and this function needed some animation too…
I have to mention that all the effects (like fadeIn, hide, etc.) and all the variables can be changed to fit your needs. You just have to play around with it for a while and you can come up with a nice live update feed or news list for your project.
1. First you need inlcude jQuery. I’ve included this directly from Google Code so it’s easier to manage.
This script works only with jQuery ver. 1.3 because of the live() function.
2. We create the functions, but first we reset the counter to 0:
You can change List item ” + counter + “ to whatever needs to be the item’s content, I’ve used this only as an example.
If you are including jQuery from your own source you have to delete the first two lines of the script:
google.load("jquery", "1.3");
google.setOnLoadCallback(function() {
and change it to the default jQuery init function:
$(document).ready(function(){
3. We need to show only the last 5 in the list so we remove the others as we add more. To accomplish this, insert the following code above the first line in the addItem() function:
if (counter>=5)removeItem();
This is relative to what you are trying to do with this script. You can set the number in the above code to any number you like, this represents the number of items showed in the list in a DESCENDING order.
4. You need to have two elements in the <BODY> of your page to use the script’s functionality, one UL or OL with the ID “items” and one button or link with the class of “add” . This can be modified as you like. You can change the ID or the Class in whatever suits your styles, but my example uses this:
» Add item to list
5. We add some CSS…This is just the way I did the styling so you don’t have to stick with it:
That’s all it takes to build this simple effect and I hope it can be completed with some awsome functions to get the needed results for your web app or web page.
Please don’t hesitate to write me your ideeas about expanding this script to make it more powerful, or even more “stylish”. Maybe we can write a nice jQuery plugin after expandig to a higher level.
Related Entries
About the author
Gergely Marton, is a self-tought web designer and developer with over seven years of experience. He owns his own little web design agency WebGurus, and runs this blog in his spare time. Usually the work gets more important for him than anything else, but he struggles to get some time to read and to play his violin.
-
Tom
-
http://www.webgurusdesignblog.com Gergely Marton
-
dan
-
http://www.webgurusdesignblog.com Gergely Marton
-
dan
-
Jsir
-
jonathan
-
http://www.essayslab.com Charlotte28
-
http://www.onuronaran.com.tr onur
-
Andrew
-
Andrew
-
http://www.btopi.com fast payday loans
-
http://www.askbuyusunasilyapilir.net Aşk Büyüsü Nasıl Yapılır
-
http://www.mark5inc.com Teeth Whitening
-
http://www.club-penguin.org/ ClubPenguinCheats
-
http://www.legalsoundz.com Music downloads
-
http://www.watchesky.com/ fade watches
-
http://www.watchesky.com/ fadewatches
-
http://www.cheapprintershop.cz.cc/ Quentin Cavey
-
http://infocusz.com/ Alyce Dombrosky
-
http://www.homeimprovementcenters.co.cc home improvement centers
-
http://standmixerattachment.co.cc/ stand mixer attachment
-
http://www.7daysshopz.com Kiera Pickar
-
http://louisvuittonstyle.org/ louis
-
http://www.t3-interactive.com Omar Khan
-
http://www.china-blockmachine.com/ Block making machine
-
http://www.snowbootscamp.com/ Women’s Classic Cardy Boots
-
http://www.co-co-chanel.com/ Cheap gucci purse
-
http://www.agico.cn oil press
-
http://www.laptopspark.com laptopspark
-
http://www.china-blockmachine.com/ Brick making machine
-
Cyrille
-
http://www.octaminds.com Octaminds Web Solutions
-
http://www.onlinecheck.com/business_loan.html Fast Business Funding
-
http://www.sherwinhermogenes.com/ Web Designer Philippines
-
Nagender
-
Nagenderpuli
-
Victor Sh 91
-
http://yepi-games.kizifriv1.com/ friv
-
http://y8-kizi.kizifriv1.com/ kizi friv
-
http://kizi-juegos.kizifriv1.com/ Kizi Juegos
-
http://www.y8u.org/ Y8
-
http://www.yepibugy.com/ Yepi
Sponsors
Recent Comments
- Y8 on Inspiration: The Art Of Michal Lisowski
- Y8 on Sleek Admin – a clean admin skin for your backend
- yepi2 on Inspiration: The Art Of Joshua M. Smith
- yepi1 on 20 Quality examples of high contrast in web design
- Tiziano on FancyPlayer Revisited – jQuery Fancybox and Flowplayer Complete Integration
Recent Posts
- Inspiration: The Art Of Joshua M. Smith
- Freebie: Material Layer Styles
- Inspiration: The Art Of Ben Hewitt
- Free Fonts For Your Next Design by Fontfabric
- Inspiration: The Art Of Michal Lisowski

