I need list of all class name of Font-Awesome

前端 未结 18 3068
傲寒
傲寒 2020-12-12 13:44

I build app that will present a lot of icons so I need list of all Font-Awesome class name like [\"fa-dropbox\",\"fa-rocket\",\"fa-globe\", ....] so on is ther

18条回答
  •  心在旅途
    2020-12-12 14:34

    Here is a snippet that works based on the loaded css. It assumes you have loaded the stylesheet with a name of font-awesome.css among other things but you could tweak this for your use. Theoretically, this will continue to work as future versions of font-awesome are released and new icons are added. That of course assume he keeps the css consistent over time.

    var icons = $.map($.map(document.styleSheets, function(s) { 
        if(s.href && s.href.endsWith('font-awesome.css')) 
            return s; 
        return null; 
    })[0].rules, function(r) { 
        if(r.cssText.indexOf('::before { content: ') > 0) 
            return r.cssText.substring(4,r.cssText.indexOf('::')); 
        return null; });
    

提交回复
热议问题