mercredi 12 juillet 2017

Javascript showing div box doesn't work

I'm sorry, I'm very new to JS but I need it for work...

Can you just quickley tell me what is wrong with this script? I just want the div box to be visible every second time when someone loads the page...

<body onload="script();">

<script type="text/javascript">
var random = Math.floor(Math.random() * 2) + 1  ;
        
        if (random<1) {
        document.getElementById('ele').style.display = 'block';
};
</script>



<div style="display: none;" id="ele">Div-Box<br />
        </div>
</body>

Cheers, Till




Aucun commentaire:

Enregistrer un commentaire