+ 1

Can you change the type of output given from an alert of the css background color in JQuery?

Ex. Alert($("#txt").css("background-color");) ; where the css is: #txt {background-color: red;} This alerts 'rgb(255, 0, 0)' Can I change this to say 'red' or '#FF0000'

21st Jan 2023, 9:53 PM
Ludwig Booysen
Ludwig Booysen - avatar
4 Answers
22nd Jan 2023, 1:08 AM
Chris Coder
Chris Coder - avatar
+ 3
Also thanks Chris Coder for the advise, you can check out this code in action on my 'rgb to hex color converter' code bit!
22nd Jan 2023, 12:27 AM
Ludwig Booysen
Ludwig Booysen - avatar
+ 2
Yes, Perhaps you may find an answer here. https://stackoverflow.com/questions/1740700/how-to-get-hex-color-value-rather-than-rgb-value If none of the answers work let me know.
21st Jan 2023, 11:58 PM
Chris Coder
Chris Coder - avatar
+ 1
Hey seemed to work very effectively! To be honest I do not exactly understand those syntaxes but if it works it works
22nd Jan 2023, 12:25 AM
Ludwig Booysen
Ludwig Booysen - avatar