Hi everybody.
Please rate my work.
A link to the example that is made in the “Glitch”.
A link to the assessment page.
Thank you all very much.
Hi everybody.
Please rate my work.
A link to the example that is made in the “Glitch”.
A link to the assessment page.
Thank you all very much.
Great work, @petrushya!
Excellently solved.
To make things simpler, instead of getAttribute()
and setAttribute()
you could use dot notation.
For example:
overlay.setAttribute('style','background-color: rgba(0,0,0,0.3)');
becomes
overlay.style.backgroundColor = 'rgba(0,0,0,0.3)';
I hope that helps.
Michael
Hi @mikoMK.
Thanks for the hint, I haven’t read about replacing the dash with camel notation yet. I wanted to write a “overlay.style.background=‘rgba(…)’;”, but the “background-color” is specified in the task.
But why doesn’t it work for “for” when creating the “label” element?
Have a nice weekend.
Pyotr
That’s a great question!
There are two attributes that have a different name in JS: for
htmlFor
and class
className
. The reason is that for
and class
are reserved words in JavaScript.
As we already saw, when using style
we need to change the CSS properties from kebab-case to camelCase. That’s because dashes are not allowed in identifiers (names of variables/methods/properties).
Thank you so much for the explanations!
Good bye.