I'm trying to click add and the content of add will appear for the first time.
After it's added, I want to click add and it will only toggle "added", instead of adding "added" on each click
Jquery:
$(function(){
var NewContent='<div class="added">Added</div>'
$(".add").click(function(){
$("#spin").after(NewContent);
});
});
HTML:
<span class="add">add</span>
<span id="spin"></span>
Here's a Fiddle: http://jsfiddle.net/Abgec/
You can simplify a lot by creating and hiding the "added" div right in the beginning.
CSS:
HTML:
jQuery:
In other words, rather than dynamically creating "Added" and then toggling visibility, just toggle visibility (starting in an invisible state).
Jquery: