JSFiddle - React, Tailwind, and code Playground
HTML
<input type="button" value="新增" id="create_new" />
<div>測試</div>
CSS
div{
border:solid 1px #666;
padding:2px;
margin:0 0 5px 0;
width:80px;
text-align:center;
}
input{
width:80px;
padding:2px;
margin:0 0 5px 0;
}
JavaScript
$(function(){
$('#create_new').click(function(){
$('body').append('<div>測試</div>');
});
});
$('div').live({
ready : function(){
var $this = $(this);
$this.attr({'title' : $this.html(), 'counter' : 0});
$this.html($this.html()+'0');
},
click : function(){
var $this = $(this),
counter = parseInt($this.attr('counter'))+1;
$this.attr('counter',counter);
$this.html($this.attr('title')+counter);
}
});