JSFiddle - React, Tailwind, and code Playground
by kasperfish
HTML
<input id="user" value="Usuario">
CSS
#user{
color:#C0C0C0
}
JavaScript
function deletevalueuser(){
el=document.getElementById('user');
if(el.value=='Usuario'){
cel=getComputedStyle(document.getElementById('user'), null);
if(rgb2hex(cel.color).toUpperCase()==='#C0C0C0'){
el.value='test';
el.style.color='black';
}
}
}
deletevalueuser();
function rgb2hex(rgb) {
if (/^#[0-9A-F]{6}$/i.test(rgb)) return rgb;
rgb = rgb.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);
function hex(x) {
return ("0" + parseInt(x).toString(16)).slice(-2);
}
return "#" + hex(rgb[1]) + hex(rgb[2]) + hex(rgb[3]);
}