javascript实现存储hmtl字符串示例
摘要:复制代码代码如下:Function.prototype.heredoc=function(){//利用function的注释来存储字符串,而...
复制代码 代码如下:
Function.prototype.heredoc = function(){
// 利用 function 的注释来存储字符串,而且无需转义。
var _str = this.toString(),
s_pos = _str.indexOf("/*")+2,
e_pos = _str.lastIndexOf("*/");
return (s_pos<0 || e_pos<0) ? "" : _str.substring(s_pos, e_pos);
}
function fn(){
/*<table>
<tr>
<td>用户名</td>
<td>密码</td>
</tr>
<tr>
<td>@name</td>
<td>zf123456</td>
</tr>
</table>*/
}
varstr_table=fn.heredoc();
console.log(str_table);
【javascript实现存储hmtl字符串示例】相关文章:
上一篇:
javascript作用域和闭包使用详解
下一篇:
jquery常用特效方法使用示例