javascript - How to clear effect of a click button using jquery -


i doing shown bellow:

$("#btn1").click(function(){     $('<div></div>').appendto('body'); }); 

it appends division again , again when click it, want when click other button there should no effect of "btn1" means want clear effect of first button after click second one.

how can this?

why not add class div btn1 adds:

$("#btn1").click(function() {     $("<div class='new-div'></div>").appendto('body'); }); 

then second button can remove -

$("#btn2").click(function() {     $(".new-div").remove(); }); 

Comments

Popular posts from this blog

iphone - Three second countdown in cocos2d -

hyperlink - how to do url routing in php -

c - Avoiding Extra Malloc in Linked List (node->next = NULL) -