欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

JavaScript實現(xiàn)存儲HTML字符串示例

 更新時間:2014年04月21日 17:26:20   作者:  
這篇文章主要介紹了JavaScript存儲HTML字符串的具體實現(xiàn),需要的朋友可以參考下
我是搞PHP的,讓我想起了<<<語法(heredoc和nowdoc),那么就為他命名heredoc吧。
復制代碼 代碼如下:

Function.prototype.heredoc = function(){
// 利用 function 的注釋來存儲字符串,而且無需轉(zhuǎn)義。
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 style="widht:20px;">@name</td>
<td>zf123456</td>
</tr>
</table>*/
}

var str_table = fn.heredoc();
console.log(str_table);

相關文章

最新評論