I need to click twice on the div (class="funfact") in order to active onclick event ff0().
Yes, I included the JS script in the HTML file.
var ffans = document.querySelector(".funfactans");
//ffans = fun fact answer
function ff0() {
if (ffans[0].style.height == '0px') {
ffans[0].style.height = '45px'
ffans[0].style.marginBottom = '10px'
ffans[0].style.paddingRight = '10px'
ffans[0].style.visibility = 'visible'
ffans[0].style.opacity = '1'
ffans[0].style.pointerEvents = 'auto'
}
<div class="facts">
<div class="funfact" onclick="ff0()">Fact1</div>
<div class="funfactans">Fact1 answer</div>
</div>
<script src="mainNew.js"></script>
document.querySelector(".funfactans").classList.add("otherclass")and put all the styles in your stylesheetdocument.querySelector(".funfactans")enough?