jQuery for Absolute Beginners: Day 5

Today, we’re going to learn how to dynamically create and remove elements. The “appendTo()”, “size()”, and “remove()” methods will be reviewed. As always, feel free to ask any questions that you might have. Enjoy!



Day 5: Creating and Removing Elements

Download the Source Code



60

Comments
  • charlie says:

    MegaTight!
    Thanks for being super cool!

  • GaVrA says:

    Excellent tutorials!

    I have sumed up everything as i watch every tut on my test page:

    http://www.arvag.net/test/jquery

    one little but i noticed so far is function you use for removing last li in this tutorial, if you remove all instances of li and keep pressing “Remove” button and then start to pressing “Add” button, “index” will start from some negative number… :P

    so just simple workaround this would be this :)

    if (i != 0){
    i–;
    };

  • Victor says:

    Jeffrey,

    Having so much fun with your video tutorials! I learned something day by day!

  • Just wondering what this would be used for on a real site??

  • xhr says:

    Jeffrey, why do you use selector “a#add”? why don’t just “#add”? The document can’t content two (or more) id=”add” and we will not use selector “somethign#add” in same document … is it logically?

  • mike on dOPe says:

    hello, i’m trying to enable the code hinting so when i type commands can view the function etc. but i can’t. i installed the plugin for jquery api in the extension manager of dreamweaver cs4 and every time i create a jquery object i just get 5 functions that aren’t helpfull. can u help me ?

  • Great tutorial, loved it :)

  • KN says:

    Useful clip however it doesn’t discuss what happens when you continue clicking remove after all the elements are gone which leads to negative values when you add again.

  • scott says:

    when the last list item is removed, that you add one, the count starts at 0. Can this be fixed. I would also like to get an idea of how this can actually be used, especially when it reverts back at refresh.

  • Harsha M V says:

    Nice video. i have a problem. since am using TEXT

    on click.. it goes to the top of the page instead of staying there. any solution how to fix this ?