+ 2
What's wrong with this code? The opacity is not changing on clicking the button.
2 ответов
+ 4
https://code.sololearn.com/W6OFoot6bJv5/?ref=app
Have a look at this code
+ 2
The setAttribute() method adds a specified attribute to an element, and gives it a specified value.
But it does not set CSS properties, try not to confuse HTML attributes with CSS properties.
Your code should work if you set it like this:
document.getElementById('text').style.opacity = 1;
For more info on how to set CSS properties via JavaScript please visit this link:
https://www.sololearn.com/learn/JavaScript/2754/