jQuery method for obtaining a font color 16 bit code

  • 2021-01-02 21:45:16
  • OfStack

This article illustrates the method of jQuery to obtain the font color 16 bit code. To share 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('');

For more information about jQuery, please visit jQuery Special Effects and Techniques Summary, jQuery Common Classic Special Effects Summary, jQuery Extension Techniques Summary, jquery Selector Methods Summary and jquery Common Operation Techniques Summary.

I hope this article has been helpful in jQuery programming.


Related articles: