From win32 color Code to set Element BackColor in jQuery -



From win32 color Code to set Element BackColor in jQuery -

i have xml file elements color available in node node's color value stored in form of win32 color value. want convert value hex value can utilize in jquery css property.

example below

<inputbackcolor>33023</inputbackcolor>

change

$("elemet").css('background-color',"#somehexvaluefrominputbackcolornode")

how can this?

your source color stored in colorref, construction in form 0x00bbggrr (in hexadecimal).

therefore, convert css representation, have to:

convert value hexadecimal string, pad hex string zeroes on left side, swap reddish , bluish channels, prepend hash sign #.

which can achieved like:

var csscolor = "000000" + parseint(sourcecolor, 10).tostring(16); csscolor = csscolor.substr(csscolor.length - 6); csscolor = "#" + csscolor.substr(4, 2) + csscolor.substr(2, 2) + csscolor.substr(0, 2)

jquery

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -