做微商城的时候用到这个东东,里面的内容不在页面显示,好奇它有什么用。下面是一个实例,理解的不全,希望大神补刀。
<br>
<br>
<meta>
<br>
<title>标题</title>
<br>
<br>
<br>
<div></div>
<br>
<input><br>
<script><br />
<li><br />
<div class="photo"><br />
<a href="#"> <img src="[UserImg]" / alt="<script type="text/html">的使用" ><br />
<br />
<p><br />
<a href="#">[UserName]:<span class="time">[CreateDate]<br />
</script>
<script></script>
<script><br />
var reg = new RegExp("\\[([^\\[\\]]*?)\\]",'igm'); //i g m是指分别用于指定区分大小写的匹配、全局匹配和多行匹配。<br />
$("#addFun").click(function() {<br />
var html = document.getElementById("commentTemplate").innerHTML;<br />
var source = html.replace(reg, function(node, key) {<br />
return {<br />
'UserImg' : '1',<br />
'UserName' : '张',<br />
'CreateDate' : '2011-1-1'<br />
}[key];<br />
});<br />
$("#comment_ul_2").append(source);<br />
});<br />
var zzl = "name:[name]";<br />
zzl = zzl.replace(reg, function(node, key) {<br />
return {<br />
'name' : '小明'<br />
}[key];<br />
});<br />
alert(zzl);<br />
</script>
AD:真正免费,域名+虚机+企业邮箱=0元
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn