1 2 3 4 5 6 7 8 9 10 11
| <script type="text/javascript"> var reg = new RegExp("\\[([^\\[\\]]*?)\\]", 'igm'); $("#addFun").click(function () { var html = document.getElementById("commentTemplate").innerHTML; var source = html.replace(reg, function (node, key) { return { 'UserImg': '1', 'UserName': 'zhang', 'CreateDate': '2011-1-1'}[key]; }); $("#comment_ul_2").append(source); }); var zzl = "name:[name]"; zzl = zzl.replace(reg, function (node, key) { return { 'name': '占占'}[key]; }); alert(zzl); </script>
|