Set background color in hex | background color hex
IfyouwanttogetthecolorofanelementwhichisinrgbformatthenyoucanconvertitfromrgbtohexformatfunctionrgbToHex(col){if(col.charAt(0)==r){col=col.replace(rgb(,).replace(),).split(,);varr=parseInt(col[0],10).toString(16);varg=parseInt(col[1],10).toString(16);varb=parseInt(col[2],10).toString(16);r=r.length==1?0+r:r;g=g.length==1?0+g:g;b=b.length==1?0+b:b;varcolHex=#+r+g+b;returncolHex;}}Callthefunctionvarcol=document.getElementById(myDiv).style.backgroundColor;alert(rgbToHex(col));//alertshexvalueHe...
If you want to get the color of an element which is in rgb format then you can convert it from rgb to hex format
function rgbToHex(col) { if(col.charAt(0)==r) { col=col.replace(rgb(,).replace(),).split(,); var r=parseInt(col[0], 10).toString(16); var g=parseInt(col[1], 10).toString(16); var b=parseInt(col[2], 10).toString(16); r=r.length==1?0+r:r; g=g.length==1?0+g:g; b=b.length==1?0+b:b; var colHex=#+r+g+b; return colHex; } }Call the function
var col=document.getElementById(myDiv).style.backgroundColor; alert(rgbToHex(col)); // alerts hex valueHere is an example[1].
References Here is an example (jsbin.com)取得本站獨家住宿推薦 15%OFF 訂房優惠
colour code check rgb to hex hex color中文 color rgb rgba color picker color palette html background color color hex color converter
本站住宿推薦 20%OFF 訂房優惠,親子優惠,住宿折扣,限時回饋,平日促銷
background-color | background color hex
background-color CSS property 是用來設定HTML元素的背景顏色,值可以是顏色亦可以是特定關鍵字-- transparent. Read More
Blog Background Color Palette | background color hex
Blog Background color palette created by seigichou that consists #feceea,#fef1d2,#a9fdd8,#d7f8ff,#cec5fa colors. Read More
Color Hex Color Codes | background color hex
Color hex is a easy to use tool to get the color codes information including color models (RGB,HSL,HSV and CMYK), css and html color codes. Read More
Colors HEX | background color hex
Colors HEX. ❮ Previous Next ❯ ..... Hexadecimal color values are also supported in all browsers. A hexadecimal color ... background-color: #00bfff; color: #ffffff; Read More
CSS background | background color hex
The background-color property sets the background color of an element. The background of an ... Example. Specify the background color with a HEX value:. Read More
CSS Color Codes | background color hex
All about CSS Color Codes, includes color picker and hex color chart. ... Color Picker Background. ◯. ◯. # R H G S B V. Hex. RGB. HSL. HSV. HWB. CMYK ... Read More
CSS: background | background color hex
HTML Background Color — HTML Color Codes | background color hex
Make colorful website backgrounds with ease. Learn how to add an HTML background color using Hex color codes, HTML color names, RGB and HSL color ... Read More
HTML Color Codes | background color hex
Easily find HTML color codes for your website using our color picker, color chart and HTML color names with Hex color codes, RGB and HSL values. Read More
Set background color in hex | background color hex
A better solution to your problem would be just to set the background color like this square.style.backgroundColor = "rgb(12,34,56)";. Otherwise ... Read More
訂房住宿優惠推薦