This js parser has both the methods you are looking for.
CSS JSON parser
Or jQuery plugin analyzer.
jQuery parser
Css example:
div div:first { font-weight: bold; -jquery: each(function() {alert(this.tagName);}) } div > span { color: red; }
JSON output sent to the callback:
{ 'div div:first' : { 'font-weight' : 'bold', '-jquery': 'each(function() {alert(this.tagName);})' }, 'div > span' : { 'color': 'red' } }
You can apply a css string to an element like this:
var cssJSON = '{ "display": "none" }'; var obj = JSON.parse(json); $("#element").css(obj);
source share