I have two divs on my webpage - one to display if JavaScript is disabled, and another if JavaScript is enabled.
The issue I am facing is that even when JavaScript is not disabled, the div containing the message stating that JavaScript is disabled briefly appears before hiding a few seconds after the page loads.
Below is a simplified version of the HTML code I am using:
<html>
<head>
<body>
<!-- This div is displayed only if JavaScript is DISABLED -->
<div class="wrapper-page" id="no-js">
<p class="text-muted m-b-0 font-13 m-t-20" style="color:red !important;font-weight: bold;">
JavaScript has been disabled message.....
</p>
</div>
<!-- end no-js div -->
<!-- This div is hidden by default, and is displayed only if JavaScript is ENABLED -->
<div class="wrapper-page" id="wrapper-page" style="display:none;">
<p>My regular content goes here...</p>
</div>
<!-- end wrapper page -->
<script src="<?php echo base_url(); ?>backOffice/assets/js/jquery.min.js"></script>
<!-- If JavaScrpt is disabled, then the main div remain not visible and only the div with the
Disabled JavaScript error message is displayed. -->
<script src="<?php echo base_url(); ?>backOffice/assets/js/disabledjs.js"></script>
</body>
</html>
Here is the JavaScript code in use:
$(document).ready(function () {
$("#no-js").hide();
$("#no-js").css('visibility','hidden');
$("#no-js").css('display','none');
$("#wrapper-page").css("display", "block");
});
I have attempted moving the JavaScript and jQuery scripts to the top, as well as switching the order of the HTML divs, but so far, none of these changes have resolved the issue for me.