Skip to content
Related Articles

Related Articles

Improve Article

jQWidgets jqxColorPicker getColor() Method

  • Last Updated : 30 Jul, 2021

jQWidgets is a JavaScript framework for making web-based applications for PC and mobile devices. It is a very powerful and optimized framework, platform-independent, and widely supported. The jqxColorPicker widget is a jQuery UI widget that is used to create a color picker.

The getColor() method is used to return the color in hex or rgb format. It does not accept any parameter and returns the color object in hex format. We use object.hex for hex code and object.r, object.g, object.b for rgb color value.




Linked Files: Download jQWidgets from link. In the HTML file, locate the script files in the downloaded folder:

<link rel=”stylesheet” href=”jqwidgets/styles/jqx.base.css” type=”text/css” />

<script type=”text/javascript” src=”scripts/jquery-1.11.1.min.js”></script>

<script type=”text/javascript” src=”jqwidgets/jqxcore.js”></script>

<script type=”text/javascript” src=”jqwidgets/jqxcolorpicker.js”></script>

The below example illustrates the jqxColorPicker getColor() method in jQWidgets:



<!DOCTYPE html>
<html lang="en">
    <link rel="stylesheet" href=
        "jqwidgets/styles/jqx.base.css" type="text/css" />
    <script type="text/javascript" 
    <script type="text/javascript" 
    <script type="text/javascript" 
        <h1 style="color: green;">
            jQWidgets jqxColorPicker getColor() Method
        <div id='jqxCP'></div>
        <input type="button" id='jqxBtn' 
            style="padding: 5px 20px" value="Get color" />
    <script type="text/javascript">
        $(document).ready(function () {
                width: 450, 
                height: 300
            $('#jqxBtn').on('click', function () {
                var color = $("#jqxCP")
                var hex = color.hex;
                var rgb = "(" + color.r + "," 
                    + color.g + "," + color.b + ")"; 
                alert("Hex Color: #" + hex 
                    + ", RGB Value: " + rgb);



My Personal Notes arrow_drop_up
Recommended Articles
Page :