سؤال

Basically I initially set certain elements to display: none; and visibility: hidden; in my css file and that make them visible with help of jQuery. I was thinking, if users have javascript disabled, that would mean that they will not see any of these hidden elements at all. How could I create a sort of a fallback in order to display this content to browsers with disabled javascript?

هل كانت مفيدة؟

المحلول

In your head, place something like :

<noscript>
    <style type="text/css">
        .hidden_by_js_class {display: block;}
    </style>
</noscript>

From MDN:

The HTML <noscript> Element defines a section of html to be inserted if a script type on the page is unsupported or if scripting is currently turned off in the browser.

نصائح أخرى

You can use the tag : http://www.w3schools.com/tags/tag_noscript.asp

<script type="text/javascript">
document.write("Javascript is On");
</script>
<noscript><span>Your Javascript is off</span></noscript>`
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top