"jquery shopping card"
Bootstrap 3.0.0 Snippet by evarevirus

<link href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css"> <script src="//netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script> <script src="//code.jquery.com/jquery-1.11.1.min.js"></script> <!------ Include the above in your HEAD tag ----------> <!DOCTYPE html><html class=''> <head><script src='//production-assets.codepen.io/assets/editor/live/console_runner-079c09a0e3b9ff743e39ee2d5637b9216b3545af0de366d4b9aad9dc87e26bfd.js'></script><script src='//production-assets.codepen.io/assets/editor/live/events_runner-73716630c22bbc8cff4bd0f07b135f00a0bdc5d14629260c3ec49e5606f98fdd.js'></script><script src='//production-assets.codepen.io/assets/editor/live/css_live_reload_init-2c0dc5167d60a5af3ee189d570b1835129687ea2a61bee3513dee3a50c115a77.js'></script><meta charset='UTF-8'><meta name="robots" content="noindex"><link rel="shortcut icon" type="image/x-icon" href="//production-assets.codepen.io/assets/favicon/favicon-8ea04875e70c4b0bb41da869e81236e54394d63638a1ef12fa558a4a835f1164.ico" /><link rel="mask-icon" type="" href="//production-assets.codepen.io/assets/favicon/logo-pin-f2d2b6d2c61838f7e76325261b7195c27224080bc099486ddd6dccb469b8e8e6.svg" color="#111" /><link rel="canonical" href="https://codepen.io/Paul34/pen/aNaxNE?limit=all&page=9&q=shop" /> <link rel='stylesheet prefetch' href='https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.min.css'><link rel='stylesheet prefetch' href='https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css'><link rel='stylesheet prefetch' href='https://maxcdn.bootstrapcdn.com/font-awesome/4.6.1/css/font-awesome.min.css'> <style class="cp-pen-styles">main { padding: 100px 0; width: 600px; margin: 0 auto; } header { height: 100px; margin-bottom: 50px; } h1 { float: left; margin: 0; } h2 { margin: 0 0 50px; } #cart-container { float: right; width: 210px; position: relative; } #itemCount { position: absolute; display: none; top: -10px; left: -10px; width: 20px; height: 20px; border-radius: 50%; background: red; color: white; text-align: center; } img { width: 100%; } .item { width: 31%; float: left; margin: 1%; } i:hover { cursor: pointer; } #shoppingCart { top: 0; left: 0; height: 100%; width: 100%; display: none; position: absolute; z-index: 9999; background: rgba(0, 0, 0, 0.6); } #cartItems { position: relative; width: 600px; left: 50%; top: 150px; margin-left: -300px; padding: 40px; box-shadow: 0 0 10px black; background: #e9e9e9; overflow: auto; } #cartItems i { position: absolute; top: 20px; right: 20px; } #cartItems .itemDetails { overflow: auto; width: 100%; margin-bottom: 40px; } #cartItems .itemImage { float: left; width: 260px; padding: 0 40px; } #cartItems .itemText { float: right; width: 260px; padding: 0 40px; } .removeItem { margin-left: 40px; } </style></head><body> <main> <header> <h1>Your Shopping Cart</h1> <div id="cart-container"> <div id="cart"> <i class="fa fa-shopping-cart fa-2x" aria-hidden="true"></i> <button class="clear">Empty Cart</button> </div> <span id="itemCount"></span> </div> </header> <div id="shoppingCart"> <div id="cartItems"> <h2>Items in your cart</h2> <i class="fa fa-times-circle-o fa-3x" aria-hidden="true"></i> </div> </div> <div class="item"> <div class="itemDetails"> <div class="itemImage"> <img src="http://lorempixel.com/300/300/sports" alt="" /> </div> <div class="itemText"> <p class="price">Price: €10</p> <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aperiam at optio nam asperiores ipsam voluptate eaque labore.</p> </div> </div> <button class="add">Add to cart</button> </div> <div class="item"> <div class="itemDetails"> <div class="itemImage"> <img src="http://lorempixel.com/300/300/technics" alt="" /> </div> <div class="itemText"> <p class="price">Price: €15</p> <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aperiam at optio nam asperiores ipsam voluptate eaque labore.</p> </div> </div> <button class="add">Add to cart</button> </div> <div class="item"> <div class="itemDetails"> <div class="itemImage"> <img src="http://lorempixel.com/300/300/fashion" alt="" /> </div> <div class="itemText"> <p class="price">Price: €20</p> <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Aperiam at optio nam asperiores ipsam voluptate eaque labore.</p> </div> </div> <button class="add">Add to cart</button> </div> </main> <script src='//production-assets.codepen.io/assets/common/stopExecutionOnTimeout-b2a7b3fe212eaa732349046d8416e00a9dec26eb7fd347590fbced3ab38af52e.js'></script><script src='//cdnjs.cloudflare.com/ajax/libs/jquery/2.2.2/jquery.min.js'></script> <script >var itemCount = 0; $('.add').click(function (){ itemCount ++; $('#itemCount').html(itemCount).css('display', 'block'); $(this).siblings('.itemDetails').clone().appendTo( "#cartItems" ).append('<button class="removeItem">Remove Item</button>'); }); $('.clear').click(function() { itemCount = 0; $('#itemCount').html('').css('display', 'none'); $('#cartItems').html(''); }); $('i').click(function(){ $('#shoppingCart').toggle(); }); $('#shoppingCart').on('click', '.removeItem', function(){ $(this).parent().remove(); itemCount --; $('#itemCount').html(itemCount); if (itemCount === 0) { $('#itemCount').html('').css('display', 'none'); $('#shoppingCart').css('display', 'none'); } }); //# sourceURL=pen.js </script> </body></html>

Related: See More


Questions / Comments:

I was looking for this !! Thanks a lot

kanachrisi () - 6 years ago - Reply 0