javascript 实现购物车页面

(2020-09-10更新:修复发现的bug,优化代码)

跟商城有关系的网站,难免会有购物车的结账界面。

我用javascript实现了增加数量/减少数量,实时计算总金额,删除该商品,选中商品/反选商品/全选/全反选...的操作。

欢迎指点!~

图片没有提供,建议自己替换。

效果如图:

 

用到的素材:加号 减号 商品图 删除图标 选中的图标和没选中的图标 
 

代码:

<!DOCTYPE html>
<html lang="zh-CN">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>document</title>
    <style>
      * {
        margin: 0;
        padding: 0;
        list-style: none;
        font-size: 16px;
        font-family: 'arial';
        font-weight: normal;
      }

      table {
        width: 1020px;
        margin: 0 auto;
        border: 1px solid gray;
        margin-top: 30px;
        border-collapse: collapse;
        text-align: center;
      }
      table tr {
        height: 100px;
        line-height: 100px;
      }
      table th:nth-child(1) {
        width: 72px;
      }
      table th:nth-child(2) {
        width: 357px;
      }
      table th:nth-child(3) {
        width: 133px;
      }
      table th:nth-child(4) {
        width: 153px;
      }
      table th:nth-child(5),
      table th:nth-child(6) {
        width: 152px;
      }

      thead {
        background: black;
        color: white;
      }
      thead tr,
      tfoot tr {
        height: 40px;
        line-height: 40px;
      }

      tbody tr {
        border-bottom: 1px solid black;
      }

      table img {
        float: left;
        width: 65px;
        height: 65px;
        margin-top: 18px;
      }
      table input[type='checkbox'] {
        width: 32px;
        heig
  • 1
    点赞
  • 44
    收藏
    觉得还不错? 一键收藏
  • 4
    评论
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值