Reputation: 323
I am showing and hiding a div Via Jquery. Is there any way to display that DIV by default if Javascript is disabled in Browser?
Upvotes: 2
Views: 146
Reputation: 1502
use<noscript></noscript>
tag to display something when javascript is disabled in browser.
Upvotes: 0
Reputation: 176
There is a <noscript>
tag :
<noscript>
<div>
Javascript is disabled.
</div>
</noscript>
If javascript is activated, the div won't be displayed.
More here.
Upvotes: 0
Reputation: 6747
You can use a <noscript>
block and inside use some CSS to make the specific div show instead of being hidden. The following code has been tested with Javascript disabled and the div shows up properly, but is hidden with Javascript enabled:
#hiddenID {
display: none;
}
<div id="hiddenID">test</div>
<noscript>
<style>
#hiddenID {
display: block;
}
</style>
</noscript>
Upvotes: 0
Reputation: 43479
Simply remove/hide that div with JS code. If no JS is enabled, than code will not be executed:
$('.fallback').remove();
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="fallback">Fallback if no JS</div>
Upvotes: 4