Suman Biswas
Suman Biswas

Reputation: 883

How to get rgb color code of color 'white' in javascript?

I want a javascript function which will take a color name as parameter and it returns the color rgb code.

Upvotes: 0

Views: 1286

Answers (1)

Lifecube
Lifecube

Reputation: 1188

You could set the style to a html element, let's say the <div id='d1'></div>

then you could check the computed color:

    var d1 = document.getElementById('d1')
    var color = window.getComputedStyle(d1, null)['color']

Upvotes: 1

Related Questions