I can console.log(2), but it didn't work when I want to show the opacity of the 'div'?
let obj = document.getElementById('fade-obj');
let btn = document.getElementById('fade-btn');
btn.addEventListener('click', function() {
console.log(obj.style.opacity);
console.log(2);
})
<div id="fade-obj" style="width:300px;height:300px;background:#000"></div>
<button id="fade-btn">click</button>