javascript - JQuery undo append -


i've got table button inside td, once press button adds text td. want remove text inside td once press button again. note this button used multiple times in table hence class attribute. method use done?

this code:

$(document).on('click', '.releasebutton', function () { // button class="releasebutton"     var label = $(this).text();     if (label == "add") { // "add" default         $(this).text("cancel");         $('.releasetd').append("<br>" + "test"); // td class="releasetd"     }     // code above works     else {         $(this).text("add");         $('.releasetd').remove("<br>" + "test");          // wrong correct code     }; }); 

you create id text inside this:

$(document).on('click', '.releasebutton', function () { // button class="releasebutton"     var label = $(this).text();     if (label == "add") { // "add" default         $(this).text("cancel");         $('.releasetd').append("<span id='textid'><br>" + "test</span>");     }     else {         $(this).text("add");         $('#textid').remove();      }; }); 

Comments

Popular posts from this blog

elasticsearch python client - work with many nodes - how to work with sniffer -

angular - Is it possible to get native element for formControl? -

Upload file with tags through OwnCloud or NextCloud API -