Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/68.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 引导获取图标代码_Javascript_Twitter Bootstrap_Twitter Bootstrap 3_Glyphicons - Fatal编程技术网

Javascript 引导获取图标代码

Javascript 引导获取图标代码,javascript,twitter-bootstrap,twitter-bootstrap-3,glyphicons,Javascript,Twitter Bootstrap,Twitter Bootstrap 3,Glyphicons,我的任务是从引导glyphicon元素(例如“\e020”)获取代码 我尝试了以下方法: html: 但在这里我只能实现字符本身,而不是原始代码 有没有办法获取“\e020”的字符串?您可以使用toString方法和16参数将字符转换为十六进制: var content = window.getComputedStyle($('#glyph')[0], ':before').content var result = '\\' + content.charCodeAt(1).toString(16

我的任务是从引导glyphicon元素(例如“\e020”)获取代码

我尝试了以下方法:

html:

但在这里我只能实现字符本身,而不是原始代码


有没有办法获取“\e020”的字符串?

您可以使用
toString
方法和
16
参数将字符转换为十六进制:

var content = window.getComputedStyle($('#glyph')[0], ':before').content
var result = '\\' + content.charCodeAt(1).toString(16);    
alert(result);

请参见您可以使用
toString
方法和
16
参数将字符转换为十六进制:

var content = window.getComputedStyle($('#glyph')[0], ':before').content
var result = '\\' + content.charCodeAt(1).toString(16);    
alert(result);

var content = window.getComputedStyle($('#glyph')[0], ':before').content
var result = '\\' + content.charCodeAt(1).toString(16);    
alert(result);