Users can set the background-color of a button through a textbox that accept RGB hexadecimal notation: ff00ff, ccaa22, etc. So I need to set the te
I linked another Question to this topic in the comments.
JS function to calculate complementary colour?
As Tejasva said you need to need to convert RGB to HSL, complement the Hue and convert it back.
I implemented the linked answer as a sample. Please upvote the original poster if this was helpful for you, because they provided the solution in fact.
Sample
http://jsfiddle.net/pLZ89/2/