将HTML字符串编码,这个函数支持 cent, yen, euro, pound, lt, gt, copy, reg, quote, amp, apos, nbsp。
- Source:
Example
// '<div>Blah & "blah" & 'blah'</div>'
str.escapeHTML('<div>Blah & "blah" & \'blah\'</div>')
str.escapeHTML('<') // '&lt;'
str.escapeHTML('¢') // '¢'
str.escapeHTML('¢ £ ¥ € © ®') // '¢ £ ¥ € © ®'
Parameters:
Name | Type | Description |
---|---|---|
str |
String | HTML字符串 |
Returns:
编码后的字符串
- Type
- String