I learn and learn more and more about HTML 5, jQuery, CSS3 and the ability to hide and disable certain elements when JavaScript is disabled or not disabled. ( <noscript> tags)
My questions:
- How to create a hyperlink ONLY if JavaScript is disabled?
- If JavaScript is enabled , how can I make sure the INSTEAD menu of the next hyperlink is displayed in my login menu ?
HTML
Simple enough, I hide my cart area and change the login link if JS is disabled.
<noscript> <style> .login-form, .js-enabled{ display: none; } .cart{ top: -80px; } </style> <div class="cart"> <a href="#" id="cart_img"> <img src="img/bag.jpg" alt="Check Cart" onmouseover="this.src='img/bag-gold.jpg'" onmouseout="this.src='img/bag.jpg'"> </a> <a href="#">Why HorseTack?</a> | <a href="#">About</a> | <a href="#">Contact</a> | <a href="http://www.LOGINPAGELINK.com">Login</a> </div> </noscript> <div class="cart js-enabled"> <a href="#" id="cart_img"> <img src="img/bag.jpg" alt="Check Cart" onmouseover="this.src='img/bag-gold.jpg'" onmouseout="this.src='img/bag.jpg'"> </a> <a href="#">Why HorseTack?</a> | <a href="#">About</a> | <a href="#">Contact</a> | <a href="#" class="login-box">Login</a> <div class="login-form"> <form class="login-frm"> <label><input type="text" placeholder="Username"></label> <label><input type="password" placeholder="Password"></label><br> <input type="submit" value="Login"><br> <a href="#">New User?</a> </form> </div> </div>
JQuery
This leads to the fact that the slide-in window for logging in (down, so as not to bring people to the login page if they are not needed)
// Login Box Pop-Up jQuery(document).ready(function() { jQuery(".login-form").hide(); //toggle the componenet with class msg_body jQuery(".login-box").click(function() { jQuery(this).next(".login-form").slideToggle(500); }); });
What I would like, instead of having a <noscript> and duplicate content, is just to make the hyperlink work only when there is no JavaScript.
I already set the page so that users know when their JS is disabled (e.g. Stack Overflow)
Any questions about my question (hope I wasn’t vague?) Ask!
source share