How make that if i push on #changeText twice or more, i get two (or more) text text
don't use .html()
which overwrites the entire innerHTML structure.
To append new html markup
use .append()
or .appendTo()
$(document).ready(function(){
$("#changeText").click(function() {
$("#textBox").append("<div>text text</div>");
});
});
or in a more jQuery'ish chaining way:
$('<div>text text</div>').appendTo($('#textBox')); // .css().fadeOut().animate().etc()
Ref.: .append(), .appendTo()
You need to create div inside #textBox and then
$("#changeText").click(function() {
$("#textBox div").append("text");
});
EDIT:
$("#changeText").click(function() {
if ( $("#textBox div").length()>0)
$("#textBox div").append("text");
else
$("#textBox").append("<div>text</div>");
});
精彩评论