So you want to check if an HTML element has an attribute? Simple boolean check, right? Wrong. getAttribute() returns either the attribute's string value or null . But here's the kicker: if the attribute exists and is set to the string "false" , it returns... the string "false" , which is truthy in JavaScript. So when you do if (element.getAttribute("disabled")) , and the attribute is literally set to disabled="false" , congratulations, your condition evaluates to true. Because the string "false" is truthy. JavaScript gonna JavaScript. Fun fact: Use hasAttribute() instead if you actually want a boolean. Or just keep debugging why your disabled button isn't disabled.