We\'d like to convert a CSS style entered as string into a JS object.
E.g.,
var input = \" border:solid 1px; color:red \";
expec
All the answers seem to need a lot of splitting- why not do a match and get all the pairs in one go?
function cssSplit(str){ var O= {}, S= str.match(/([^ :;]+)/g) || []; while(S.length){ O[S.shift()]= S.shift() || ''; } return O; }