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


4/10/2019 10:18:21 AM

Piyush Kumar

2 Answers

New Answer


https://code.sololearn.com/W6OFoot6bJv5/?ref=app Have a look at this code


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/