hello JavaScript模板
<script style="display:none" id="template" type="text/html">
昵稱: {$data.nickname}
注冊時(shí)間: {$data.intime}
</script>
其實(shí)用html標(biāo)簽也是可以,個(gè)人還是喜歡用script標(biāo)簽。
之后用JavaScript或jquery來獲取id是template的html內(nèi)容,然后顯示在指定的位置。
jquery代碼
$(function(){
var htmlTemplate = $('#template').html();
$('div.newContent').html(htmlTemplate);
});