[jQuery] Append element once
Hi, just learn jQuery today and have the first question.
I want to append a line of html code with onclick, but I want to
append it only one time no matter how many times the users click. How
do I do it?
The code below works but it appends the additional code after every
click.
############# SCRIPT:
<script>
$(function() {
$("#divZ2-title").click(function() {
$("#divZ2").append("<strong>This is just added</strong>");});
});
</script>
############# HTML
<span id="divZ2-title"><a href="#">jQuery Link 2:</a></span>
<div id="divZ2">
<h2>Original Text 2</h2>
</div>