ﮔﺎﻫﯽ ﺑﻪ ﻫﻨﮕﺎﻡ ﻃﺮﺍﺣﯽ ﺻﻔﺤﺎﺕ ﻭﺏ
ﻭ ﯾﺎ ﻧﻮﺷﺘﻦ ﺗﻮﺍﺑﻊ ﺟﺎﻭﺍ ﺍﺳﮑﺮﯾﭙﺖ ﻧﯿﺎﺯ
ﭘﯿﺪﺍ ﻣﯽ ﮐﻨﯿﻢ ﮐﻪ ﺭﻧﮓ ﯾﮏ element ﺭﺍ
ﻣﻌﮑﻮﺱ ﻧﻤﺎﯾﯿﻢ.
ﺗﺎﺑﻌﯽ ﮐﻪ ﺑﺮﺍﯼ ﺷﻤﺎ ﺁﻣﺎﺩﻩ ﮐﺮﺩﻩ ﺍﻡ
ﺍﯾﻦ ﻋﻤﻠﯿﺎﺕ ﺭﺍ ﺑﻪ ﺭﺍﺣﺘﯽ ﺑﺮﺍﯼ ﺷﻤﺎ
ﺍﻧﺠﺎﻡ ﻣﯽ ﺩﻫﺪ.
function invertColor(control) {
var element =
document.getElementById
(control.getAttribute('id'));
var style =
window.getComputedStyle
(element);
var color =
style.getPropertyValue('color');
var digits = /(.*?)rgb\((\d+), (\d
+), (\d+)\)/.exec(color);
var red = parseInt(digits[2]);
var green = parseInt(digits[3]);
var blue = parseInt(digits[4]);
var invertedColor = [255 - red,
255 - green, 255 - blue];
invertedColor = 'rgb(' +
invertedColor[0] + ', ' +
invertedColor[1] + ', ' +
invertedColor[2] + ')';
element.style.color =
invertedColor;