Is it possible to find CSS rules from an HTML node via JavaScript?

前端 未结 5 1291
深忆病人
深忆病人 2020-12-09 21:49

I want to get an element in the DOM and then lookup what rules in my CSS file(s) are contributing to it\'s appearance. Similar to what firebug or webkits inspector does. Is

5条回答
  •  难免孤独
    2020-12-09 22:37

    Is it possible? Absolutely...is it simple (especially cross-browser with IE in the mix), not so much. If you're really interested in doing this, check out the Firebug Lite CSS source here. At least the methods are decently commented showing what information each is fetching.

    ....or if you're wanting simply to inspect in a browser that doesn't have an inspector, just use Firebug Lite.

提交回复
热议问题