DEV Community

Discussion on: JavaScript Should Be Your Last Resort

possibly1 profile image
possibly1 • Edited

So I tried it, and JS is alot easer to debug than css.

<!DOCTYPE html>
<html>
<style>

#pageHeading {
display : none;
}


#pageHeading {
display : block;
}
</style>
<body>

<h1 id="pageHeading">Hide Me Now</h1>

<button onclick="myHideDomElementFunction('#pageHeading')">Try it</button>

<script>

const myHideDomElementFunction = targetElement => document.querySelector(targetElement).style.display = "none";

const myHideDomElementFunction = targetElement => document.querySelector(targetElement).style.display = "none";

</script>

</body>
</html>
Enter fullscreen mode Exit fullscreen mode
Thread Thread
ojrask profile image
Otto Rask

Easier how? I am not certain how that example should be read or executed to validate your point?