From a widest compatibility with various browsers perspective, what is the best way to show content for only JavaScript enabled clients? There have been similar questions, however, they are old and in conflict.
- How to wrap <noscript> tag to hide content when javascript disable
- Is there a HTML opposite to <noscript>?
I have seen other options, however, it seems like these two are the best?
<!DOCTYPE html>
<html>
<head>
<title>anti-noscript</title>
<noscript><style> .yes_script1 { display: none } </style></noscript>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.js" type="text/javascript"></script>
<script type='text/javascript'>
$(function(){
$('.yes_script2').show();
});
</script>
<style>
.yes_script2{display:none;}
</style>
</head>
<body>
<p class="yes_script1">Show to JavaScript clients only.</p>
<noscript>Show to non-JavaScript clients only.</noscript>
<p class="yes_script2">Show to JavaScript clients only.</p>
</body>
</html>