+ 2

What's wrong with this code? The opacity is not changing on clicking the button.

https://code.sololearn.com/WRYRuKsI1ei1/?ref=app

10th Apr 2019, 10:18 AM
Piyush Kumar
Piyush Kumar - avatar
2 odpowiedzi
+ 4
https://code.sololearn.com/W6OFoot6bJv5/?ref=app Have a look at this code
10th Apr 2019, 11:33 AM
Versha Mishra
Versha Mishra - avatar
+ 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/
10th Apr 2019, 11:38 AM
Ryan
Ryan - avatar