jQuery Plugin For Determine The Brightness Of The Background Color - colourBrightness

File Size: 2.41 KB
Views Total: 2224
Last Update:
Publish Date:
Official Website: Go to website
License: MIT
   
jQuery Plugin For Determine The Brightness Of The Background Color - colourBrightness

colourBrightness is a tiny jQuery plugin used to determine the brightness of the background color and then add the class light if the color is light and dark if the color is dark to the target element.

How to use it:

1. Include jQuery javascript library and jQuery colourBrightness plugin on the web page.

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="jquery.colourBrightness.min.js"></script>

2. Call the plugin with target element.

<script>
  $(document).ready(function(){
    $('.YOURELEMENT').colourBrightness();
  });
</script>

3. Custom the color of your target element in CSS.

.light {
  color: #000;
}
.dark {
  color: #fff;
}

Change logs:

  • Added RGBa support
  • bugfix

This awesome jQuery plugin is developed by jamiebrittain. For more Advanced Usages, please check the demo page or visit the official website.