jquery Gets the problem of Background-color color values in the style _jquery

Source: Internet
Author: User
Today, using jquery to get the value of the Background-color in the style, we find that the color value in IE is not the same as that of Chrome and Firefox, ie displays "#ffff00" in the hex format, while Chrome, Firefox is in GRB format display "RGB (255,255,0)", and I need hexadecimal color value, used to store in the database, find the next piece of code on the Internet can solve this problem:
Copy Code code as follows:

$.fn.gethexbackgroundcolor = function () {
var RGB = $ (this). CSS (' Background-color ');
if (!$.browser.msie) {
RGB = Rgb.match (/^rgb\ (\d+), \s* (\d+), \s* (\d+) \) $/);
function Hex (x) {
Return ("0" + parseint (x). toString). Slice (-2);
}
rgb= "#" + Hex (rgb[1]) + hex (rgb[2]) + hex (rgb[3));
}
return RGB;
}

This is all displayed in hex format and has been validated.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.