(function($) {
$(document).ready(function() {
try {
var Tag = function(parent, elemt) {
this.parent = parent;
this.elemt = elemt;
};
Tag.prototype.value = function(text) {
this.elemt.show();
this.elemt.find('a').text(text).attr('href', '#' + text);
return this;
};
Tag.prototype.show = function() {
this.elemt.show();
return this.parent;
};
var TagList = function() {
this.elemt = $('#tags');
this.template = this.elemt.find('.tag-list .tag').first();
this.template.hide();
};
TagList.prototype.newTag = function() {
var tag = this.elemt.find('.tag-list .tag').first();
tag.clone().insertBefore(tag);
return new Tag(this, tag);
};
var tagList = new TagList();
for(var index = 0; index < 100; ++index) {
tagList.newTag().value('afd'+index).show();
}
} catch(e) {
alert(e);