jquery css color value returns RGB? -


in css file:

a, a:link, a:visited { color:#4188fb; } a:active, a:focus, a:hover { color:#ffcc00; } 

i tried with:

var link_col = $("a:link").css("color"); alert(link_col); // returns rgb(65, 136, 251) 

how can hex code?

*** edit: found answer here:
background-color hex javascript variable

shame on me, have search bit better before posting..

some adjustes function

$.fn.gethexbackgroundcolor = function() {     var rgb = $(this).css('background-color');     if (!rgb) {         return '#ffffff'; //default color     }     var hex_rgb = rgb.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);      function hex(x) {return ("0" + parseint(x).tostring(16)).slice(-2);}     if (hex_rgb) {         return "#" + hex(hex_rgb[1]) + hex(hex_rgb[2]) + hex(hex_rgb[3]);     } else {         return rgb; //ie8 returns background-color in hex format make                 compatible, can improve checking if format in hexadecimal     } } 

Comments

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -