📜 ⬆️ ⬇️

Instead of the tag

Sometimes, it is extremely rare to need to hide, or show a part of the tags in the event that javascript is turned on or turned off.
Of course, there is <noscript> but it implements only a part of the logic - it hides a part of the code if javascript is enabled. Hide part of the code if javascript is turned off; there is no standard option.
More precisely, it is possible to add some code with the help of a script, but not quite that.

What can be done instead?

Add to the header code:
< style type ="text/css" > .script{display:none;} </ style >
< script type ="text/javascript" language ="JavaScript" >
document .write( '<style type="text/css">.noscript{display:none;} .script{display:inherit;} </style>' );
</ script >



If javascript is disabled, the style will be active.
.script{display:none;}

')
They can mark the buttons that perform ajax-ing actions, etc.
for example, the button "Update comments"


If javascript is enabled, this style will be overlapped by another.
.noscript{display:none;}
.script{display:inherit;}


With the noscript style, alternative controls can be marked.

Of course, without all this you can easily and do. :)

Source: https://habr.com/ru/post/51812/


All Articles