Điề*_*uan 2 javascript css font-awesome
我们可以获得伪元素:
elem   = document.getElementById('element');
result = window.getComputedStyle(elem, ':before').getPropertyValue('content');
但结果返回“?”
有没有办法从 CSS 文件中获取值?(类似于“\a8xx”)
感谢大家的回答,我找到了解决我的问题的方法:
icons = $('body *');
for (var i = 0; i < icons.length; i++)
{
    elem = icons[i];
    before_content = window.getComputedStyle(elem, ':before').getPropertyValue('content').charCodeAt(1).toString(16);
    after_content  = window.getComputedStyle(elem, ':after' ).getPropertyValue('content').charCodeAt(1).toString(16);
    console.log(before_content, after_content);
}
就像
'?'.charCodeAt(0) // 57661
如果您想将其转换为十六进制,请应用toString(16):
'?'.charCodeAt(0).toString(16) // e13d
参考:
| 归档时间: | 
 | 
| 查看次数: | 108 次 | 
| 最近记录: |