1
每次調用該腳本時,我都希望爲輸入字段指定一個唯一名稱,並且名稱不應該類似。怎麼能做到這一點?如何通過手柄條爲動態元素賦予唯一的名稱?
<button>Add new field</button>
<script type="text/x-handlebars-template" id="file_name">
<input type="file" >
</script>
<script type="text/javascript">
$('button').on('click',function(){
var template = $('#file-name').html();
var source = Handlebars.compile(template);
$('body').append(source());
});
</script>
使用類名?或者使用變量? http://handlebarsjs.com/block_helpers.html –
使用類名或ID – xxCodexx