This code snippet shows how to perform different actions when Javascript is enabled or disabled. In this example, if Javascript is enabled, the add to cart button will show a pop-up message notifying the user that the item has been added. If, however, JS is disabled, it takes the user to “cart.html”.

<!doctype html>
	<a href="" id="add-to-cart" onclick="fun()"></a>
		document.getElementById("add-to-cart").innerHTML="Add to Cart";
		function fun() {
			alert("Item Added!");
		<a href="cart.html">Add to Cart</a>