user2699175
user2699175

Reputation: 1069

How to add new list not to replace the list

I have a listing, which this list will increase when the user add new. Currently, when user click add button, it will replace the old one with the new one, I want to remain the old value, and add the new value when user click Add button.

I know something to do at this part, but I don't have any idea on how to do it. Please help, thanks.

    if(radio == '1'){
        $( "#summary" ).html( "<li class='holi'>Every Week</li>" ); 
    }   

Add New List

Upvotes: 0

Views: 51

Answers (3)

Hitesh Chandwani
Hitesh Chandwani

Reputation: 159

Inside li tag make two span, one for content and one for edit link

$('.editlinkclass').on('click',function(){

//this will give you content span and you can do whatever you want to do with this
$(this).prev();
})

Upvotes: 0

Satpal
Satpal

Reputation: 133423

You need to use .append().

$( "#summary" ).append( "<li class='holi'>Every Week</li>" ); 

Fiddel Demo

Upvotes: 0

Ayush
Ayush

Reputation: 42450

use .append() instead of .html() to append to the list.

This assumes #summary is the ul you want to add to. If, instead, it is the containing div, you can modify the selector to $("#summary ul").

JSFiddle

Upvotes: 2

Related Questions