I am doing something as shown bellow:
$("#btn1").click(function(){
$('<div></div>').appendTo('body');
});
It appends the division again and again when I click it, but what I want is when I click other button then there should be no effect of "btn1" means I want to clear the effect of first button after I click the second one.
How I can do this?
Why not add a class to the div that btn1
adds:
$("#btn1").click(function() {
$("<div class='new-div'></div>").appendTo('body');
});
Then you second button can remove it like so -
$("#btn2").click(function() {
$(".new-div").remove();
});
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments