將css選擇器提取爲字符串的最簡單方法是什麼?如何解析並提取CSS選擇器爲字符串?
鑑於此輸入:
#article{width:690px;overflow:hidden}
#article h2:first-child a{text-decoration:none}
#works .project p:last-child{margin-top:20px;font-size:13px}
#works .project img, #works .info img{width:680px;min-height:400px;border:1px dotted #ccc;margin-bottom:40px}
我怎樣才能選擇列表像這樣:
var selectors = ['#article','#article h2:first-child a','#works .project p:last-child','#works .project img']
[CSS語法/ abstracter的可能重複?如何將樣式錶轉換爲對象](http://stackoverflow.com/questions/2226869/css-parser-abstracter-how-to-convert-stylesheet-into-object) –
[使用Javascript RegExp匹配CSS選擇器](http://stackoverflow.com/questions/5481749/matching-css-selectors-with-a-javascript-regexp) – BoltClock