Skip to content

Instantly share code, notes, and snippets.

@kopiro
Created March 3, 2012 19:02
Show Gist options
  • Save kopiro/1967540 to your computer and use it in GitHub Desktop.
Save kopiro/1967540 to your computer and use it in GitHub Desktop.
Invert a CSS gradient with JS
gradientInvertor = function(s)
{
var m = s.match(/(\#[a-z0-9]{6}).*(\#[a-z0-9]{6})/);
s=s.replace( new RegExp(m[1], "g"), m[2].replace(/\#/g, '$');
s=s.replace( new RegExp(m[2], "g"), m[1]);
s=s.replace( /\$/g, '#');
alert(s);
return s;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment