Your script code should be this;
$(".more").click(function() {
$("#container").append("<div class='box'><a href='#'>x</a></div>");
var count = $(".box").length;
$("p").text("There are " + count + " boxes.");
if(count>2)
{
$(".more").hide();
}
$(".box a").click(function() {
$(this).parent().remove();
var count = $(".box").length;
$("p").text("There are " + count + " boxes.");
if(count<3)
{
$(".more").show();
}
});
});
here is fiddle