Home  >  Article  >  Web Front-end  >  How to get the 16-bit code of font color with jQuery_jquery

How to get the 16-bit code of font color with jQuery_jquery

WBOY
WBOYOriginal
2016-05-16 15:14:461627browse

The example in this article describes how jQuery obtains the 16-bit code of font color. Share it with everyone for your reference, the details are as follows:

var i = $(this).css('color');
var o = i.match(/^rgb\((\d+),\s*(\d+),\s*(\d+)\)$/);
 delete (o[0]);
 for (var n = 1; n <= 3; ++n) {
 o[n] = parseInt(o[n]).toString(16);
 if (o[n].length == 1) o[n] = '0' + o[n];
 }
var s = o.join('');

Readers who are interested in more jQuery-related content can check out the special topics on this site: "JQuery drag effects and techniques summary", "jQuery common classic special effects summary", " jQuery extension skills summary", "jquery selector usage summary" and "jquery common operation skills summary"

I hope this article will be helpful to everyone in jQuery programming.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn