jquery Usage Summary

Source: Internet
Author: User

1. jquery Gets the problem of color values in CSS styles

Transferred from: http://blog.csdn.net/cwj649956781/article/details/23261529

jquery get CSS style color values in the problem, different browser format different solutions, the need for friends can refer to

When you get the value of Background-color in a style with jquery, you find that the color values you get are "#ffff00" in hex format in the IE10 below, while IE10, Chrome, and Firefox are displayed in GRB format RGB ( 255,0,0) ", due to the need to judge the color value processing, so need to get a uniform color format, preferably hex format, convenient processing point. A search, from a foreign site to get a piece of code:

Copy CodeThe code is as follows:
$.fn.gethexbackgroundcolor = function () {
var RGB = $ (this). CSS (' Background-color ');
RGB = Rgb.match (/^rgb\ (\d+), \s* (\d+), \s* (\d+) \) $/);
function Hex (x) {return ("0" + parseint (x). toString). Slice (-2);}
return rgb= "#" + Hex (rgb[1]) + hex (rgb[2]) + hex (rgb[3]);
}


The above definition is a jquery function that we can pass through $ ("#bg"). Gethexbackgroundcolor (); Gets the RGB value of the Background-color to the label id= "BG".

Here is a small change, is to add a judgment, if the display hex value (IE10 below) directly take the value, if the non-IE browser will convert the value to RGB format:

Copy CodeThe code is as follows:
$.fn.getbackgroundcolor = function () {
var RGB = $ (this). CSS (' Background-color ');
if (RGB >= 0) return rgb;//if it is a hex value then return directly
else{
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;
}
RGB Color Conversion Hex Color
Translator is only suitable for IE Kernel browser
Convert RGB colors to hexadecimal colors:
 
Hex color converted to RGB color:
 


Hex Color Query
Color English code Image description Hexadecimal Rgb
Lightpink Light Pink #FFB6C1 255,182,193
Pink Pink #FFC0CB 255,192,203
Crimson Scarlet #DC143C 220,20,60
Lavenderblush Blush of Light Purple #FFF0F5 255,240,245
Palevioletred Pale violet-Red #DB7093 219,112,147
Hotpink Passion for Pink #FF69B4 255,105,180
Deeppink Dark Pink #FF1493 255,20,147
Mediumvioletred Moderate Violet-Red #C71585 199,21,133
Orchid The Purple Orchid #DA70D6 218,112,214
Thistle Thistle #D8BFD8 216,191,216
Plum Plum #DDA0DD 221,160,221
Violet Violet #EE82EE 238,130,238
Magenta Magenta #FF00FF 255,0,255
Fuchsia Lantern Begonia (Purple red) #FF00FF 255,0,255
Darkmagenta Deep Magenta #8B008B 139,0,139
Purple Purple #800080 128,0,128
Mediumorchid The Medium orchid Violet #BA55D3 186,85,211
Darkvoilet Dark Violet #9400D3 148,0,211
DarkOrchid Deep Orchid Violet #9932CC 153,50,204
Indigo Indigo #4B0082 75,0,130
Blueviolet The blue of the dark violet #8A2BE2 138,43,226
Mediumpurple Moderate purple. #9370DB 147,112,219
Mediumslateblue Medium Slate dark blue Grey #7B68EE 123,104,238
Slateblue Slate dark Blue Grey #6A5ACD 106,90,205
Darkslateblue Deep Rock dark Blue grey #483D8B 72,61,139
Lavender Lavender Flower Lavender #E6E6FA 230,230,250
Ghostwhite Ghost of the White #F8F8FF 248,248,255
Blue Blue #0000FF 0,0,255
MediumBlue A moderate Blue #0000CD 0,0,205
Midnightblue Midnight blue. #191970 25,25,112
Darkblue Dark blue #00008B 0,0,139
Navy Navy blue #000080 0,0,128
Royalblue Imperial Blue #4169E1 65,105,225
Cornflowerblue The blue of the Cornflower #6495ED 100,149,237
Lightsteelblue Light Steel Blue #B0C4DE 176,196,222
Lightslategray Light Slate Grey #778899 119,136,153
Slategray Slate Grey #708090 112,128,144
Doderblue Dodge Blue #1E90FF 30,144,255
AliceBlue Alice Blue #F0F8FF 240,248,255
Steelblue Steel Blue #4682B4 70,130,180
Lightskyblue Light Blue #87CEFA 135,206,250
Skyblue Azure #87CEEB 135,206,235
Deepskyblue Deep sky Blue #00BFFF 0,191,255
LightBlue Light #ADD8E6 173,216,230
Powderblue Gunpowder Blue #B0E0E6 176,224,230
Cadetblue Military Academy Blue #5F9EA0 95,158,160
Azure Blue #F0FFFF 240,255,255
Lightcyan Light Cyan #E1FFFF 225,255,255
Paleturquoise The Emerald of the pale #AFEEEE 175,238,238
Cyan Cyan #00FFFF 0,255,255
Aqua Aqua Green #00FFFF 0,255,255
Darkturquoise Deep Emerald #00CED1 0,206,209
Darkslategray Dark Slate Grey #2F4F4F 47,79,79
Darkcyan Dark Cyan #008B8B 0,139,139
Teal Water Duck Color #008080 0,128,128
Mediumturquoise A medium Emerald #48D1CC 72,209,204
Lightseagreen Shallow Ocean Green #20B2AA 32,178,170
Turquoise Emerald #40E0D0 64,224,208
Auqamarin Green Jade \ Green #7FFFAA 127,255,170
Mediumaquamarine Moderate Turquoise #00FA9A 0,250,154
Mediumspringgreen The green of moderate spring #F5FFFA 245,255,250
Mintcream Mint Cream #00FF7F 0,255,127
Springgreen The Green of Spring #3CB371 60,179,113
Seagreen Ocean Green #2E8B57 46,139,87
Honeydew Honey #F0FFF0 240,255,240
LightGreen Light Green #90EE90 144,238,144
Palegreen Pale green. #98FB98 152,251,152
Darkseagreen Deep Ocean Green #8FBC8F 143,188,143
Limegreen Lime Green #32CD32 50,205,50
Lime Sour Orange #00FF00 0,255,0
Forestgreen Forest Green #228B22 34,139,34
Green Pure Green #008000 0,128,0
Darkgreen Dark green #006400 0,100,0
Chartreuse Chart Wine Green #7FFF00 127,255,0
Lawngreen Lawn Green #7CFC00 124,252,0
Greenyellow Green Yellow #ADFF2F 173,255,47
Olivedrab Olive Earthy Brown #556B2F 85,107,47
Beige Beige (light brown) #6B8E23 107,142,35
Lightgoldenrodyellow Light Autumn Kylin Yellow #FAFAD2 250,250,210
Ivory Ivory #FFFFF0 255,255,240
Lightyellow Light Yellow #FFFFE0 255,255,224
Yellow Pure Yellow #FFFF00 255,255,0
Olive Olive #808000 128,128,0
Darkkhaki Dark Khaki Fabric #BDB76B 189,183,107
LemonChiffon Lemon Tulle #FFFACD 255,250,205
Palegodenrod Ash Autumn Kylin #EEE8AA 238,232,170
Khaki Khaki #F0E68C 240,230,140
Gold Gold #FFD700 255,215,0
Cornislk Corn Color #FFF8DC 255,248,220
Goldenrod Autumn Kylin #DAA520 218,165,32
Floralwhite Flower of the White #FFFAF0 255,250,240
Oldlace Old Lace-up strap #FDF5E6 253,245,230
Wheat Wheat color #F5DEB3 245,222,179
Moccasin Deer Shoes #FFE4B5 255,228,181
Orange Orange #FFA500 255,165,0
Papayawhip Papaya #FFEFD5 255,239,213
Blanchedalmond Bleached almonds. #FFEBCD 255,235,205
Navajowhite Navajo White #FFDEAD 255,222,173
Antiquewhite The ancient White #FAEBD7 250,235,215
Tan Tanned #D2B48C 210,180,140
Brulywood A sturdy tree #DEB887 222,184,135
Bisque (thick soup) cream, tomato, etc. #FFE4C4 255,228,196
Darkorange Dark Orange #FF8C00 255,140,0
Linen Linen cloth #FAF0E6 250,240,230
Peru Peru #CD853F 205,133,63
Peachpuff Peach #FFDAB9 255,218,185
Sandybrown Sandy Brown #F4A460 244,164,96
Chocolate Chocolate #D2691E 210,105,30
SaddleBrown Saddle Brown #8B4513 139,69,19
SeaShell Sea shells #FFF5EE 255,245,238
Sienna Yellow Ochre Yellow #A0522D 160,82,45
Lightsalmon Light Fresh Meat (salmon) color #FFA07A 255,160,122
Coral Coral #FF7F50 255,127,80
Orangered Orange Red #FF4500 255,69,0
DarkSalmon Deep meat (salmon) color #E9967A 233,150,122
Tomato Tomato #FF6347 255,99,71
Mistyrose Mist Rose #FFE4E1 255,228,225
Salmon Fresh Meat (salmon) color #FA8072 250,128,114
Snow Snow #FFFAFA 255,250,250
Lightcoral Light Coral Color #F08080 240,128,128
Rosybrown Rose Brown #BC8F8F 188,143,143
Indianred Indian Red #CD5C5C 205,92,92
Red Pure Red #FF0000 255,0,0
Brown Brown #A52A2A 165,42,42
Firebrick Firebrick #B22222 178,34,34
Darkred Dark red #8B0000 139,0,0
Maroon Maroon #800000 128,0,0
White White #FFFFFF 255,255,255
WhiteSmoke White #F5F5F5 245,245,245
Gainsboro Gainsboro #DCDCDC 220,220,220
Lightgrey Light Grey #D3D3D3 211,211,211
Silver Silvery white #C0C0C0 192,192,192
Darkgray Dark grey #A9A9A9 169,169,169
Gray Grey #808080 128,128,128
Dimgray Dim grey #696969 105,105,105
Black Pure Black #000000 0,0,0

jquery Usage Summary

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.