DOM issue, I guess ?! | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

DOM issue, I guess ?!

I created a webpage to convert an RGB color to hex and vice versa .. js code works I'm kinda sure of that, ot was a challenge in the first place and I finished it (only js codes).. but when created this page it doesn't for some reason.. any help would be appreciated https://code.sololearn.com/W4wue1bYM26h/?ref=app https://code.sololearn.com/W4wue1bYM26h/?ref=app

24th Jun 2020, 1:53 PM
Ali Kh
Ali Kh - avatar
3 Answers
+ 3
var result = document.querySelector('#res').innerHTML; <-- This is your problem The variable result is a string instead of the HTMLHEADING object you need to display results of the toHEX() and toRGB() functions. var result = document.querySelector('#res'); result.innerText or textContent
24th Jun 2020, 2:47 PM
ODLNT
ODLNT - avatar
+ 2
Ali Kh It is the small problems that bite us in the butt most of the time.😉 I'm glad I could help.
24th Jun 2020, 3:59 PM
ODLNT
ODLNT - avatar
+ 1
Thank you a lot.. all is clear now😃, previously I stored the element 'text' in the variable.. so no change was done on the element itself. A small issue, yet made the whole code fail😬 Again, thanks for your help 🙏
24th Jun 2020, 3:41 PM
Ali Kh
Ali Kh - avatar