python-Web-django-商城-购物车商品加减
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>lili</title>
<script src="js/jQuery-1.8.2.min.js" type="text/javascript"></script>
</head>
<body>
<table>
<tr>
<td><input type="checkbox" id="allCheck">全选</td>
<td>商品名称</td>
<td>单价</td>
<td>数量</td>
<td>小计</td>
<td>操作</td>
</tr>
<tr>
<td><input type="checkbox" class="singleCheck"></td>
<td>女装</td>
<td>100</td>
<td class="smallnum"><span class="plus2">-</span><input type="text" value="1" size="1" class="num"><span class="plus">+</span></td>
<td class="smallMoney">100</td>
<td><a href="javascript:;" class="del">删除</a></td>
</tr>
<tr>
<td><input type="checkbox" class="singleCheck"></td>
<td>男装</td>
<td>50</td>
<td class="smallnum"><span class="plus2">-</span><input type="text" value="1" size="1" class="num"><span class="plus">+</span></td>
<td class="smallMoney">50</td>
<td><a href="javascript:;" class="del">删除</a></td>
</tr>
</table>
<div>共<span class="totalNum">0</span>件商品,共<span class="totalPrice">0</span>元</div>
</body>
</html>
<!-- 输入 全选,单选,+,-,删除 -->
<!-- 输出 小计,总件数,总数量 -->
<!-- 函数 smallMoney() ,total(),allCheck() -->
<script>
//小计函数
function smallMoney(arg,p){
// 输入jq对象和+-
var num = arg.val()
if(p=='+'){
num ++;
};
if(p=='-'){
num --;
};
arg.val(num);
// 获取单价
var smallP = arg.parent().prev().text();
// 小计
arg.parent().next().text(smallP*num)
};
//总件数,总数量函数
function total(){
// 输入
var totalNum = 0;
var totalPrice = 0;
// 遍历singleCheck
$('.singleCheck').each(function(){
if($(this).is(':checked')){
num_Num += Number($(this).parent().parent().find('.smallnum .num').val());
num_Price += Number($(this).parent().parent().find('.smallMoney').text())
}
});
// 修改总件数和总数量
$('.totalNum').text(num_Num);
$('.totalPrice').text(num_Price)
};
//全选函数
function allCheck(){
if($(t).is(':checked')){
$('.singleCheck').prop("checked", true)
}else{
$('.singleCheck').prop("checked", false)
};
};
// 点击全选
$('#allCheck').click(function(){
allCheck();
total();
});
// 点击单选
$('.singleCheck').click(function(){
total();
});
// 点击+
$('.plus').click(function(){
singlePrice($(this).prev(),'+');
total()
});
// 点击-
$('.plus2').click(function(){
singlePrice($(this).next(),'-');
total()
});
// 点击删除
$('.del').click(function(){
$(this).parent().parent().remove();
total()
})
</script>
python-Web-django-商城-购物车商品加减的更多相关文章
- web框架实现购物车数量加减
企业开发中经常是团队协作,每个人分配一个小的模块,比如说购物车模块,数量加减这一块人们首先想到的就是通过jquery实现,其实作为一个后端接口开发的程序猿也可以用自己更擅长的后端的逻辑代码来实现,那我 ...
- js jquery 权限单选 bug修改以及正确代码 购物车数量加减
效果图废话不多直接上代码 用的avalon渲染,其实都是一样的 <div class="shop-arithmetic"> <a href="javas ...
- 购物车数字加减按钮HTML+CSS+JS(有需要嫌麻烦的小伙伴拿走不谢)
之前在写详情页的时候,如下图 因为自己嫌麻烦,就去看其他网站是怎么写的,想直接拿来用,后来看来看去觉得写得很麻烦,于是最后还是决定自己写,附上HTML+CSS+JS代码,一条龙一站式贴心服务2333 ...
- python web -- django
一. 安装 django $ pip install django (env)$ python >> import django >> django.VERSION >& ...
- python web——Django架构
环境:windows/linux/OS 需要的软件:Firefox 浏览器(别的也可以 不过firfox和python的webdriver兼容性好) git版本控制系统(使用前要配置 用户 编辑器可以 ...
- 微信小程序——购物车数字加减
上一篇,我们有讲到如何造一个购物车弹层.今天来说一下,购物车数量的加减如何实现. 主要思路就是在data里面定义一个属性,属性值就是这个数量.点击+的时候就+1,点击-的时候就-1,再结合setDat ...
- python datetime库使用和时间加减计算
datetime库使用 一.操作当前时间 1.获取当前时间 >>> import datetime >>> print datetime.datetime.now( ...
- python web django base skill
web框架本质 socket + 业务逻辑 框架实现socket tonado node.js 使用WSGI实现socket django flask 自己实现框架思路 wsgiref socket ...
- Vue: 购物车数量加减按钮
效果图: HTML: <div class="label"> <p class="buy_num">购买数量</p> < ...
随机推荐
- CSS基础学习 16.CSS过渡
- iOS 中通过kvc 获取数组的均值、求和、最大最小值等
NSArray *values = @[@, @, @, @, @, @, @, @, @, @, @, @, @, @, @, @, @]; NSNumber *avg = [values valu ...
- k8s-应用部署
该demo主要作为一个dubbo项目通过maven自动化docker打包插件发布到镜像仓库样例工程.该wiki后面同时会提供k8s部署zk,mysql,应用包的整个过程.该项目大体功能:zk作为注册中 ...
- Codeforces Round #588 (Div. 2) E. Kamil and Making a Stream(DFS)
链接: https://codeforces.com/contest/1230/problem/E 题意: Kamil likes streaming the competitive programm ...
- Spring Boot 前期篇
在学习springboot之前,学习一下Spring的java配置. 1. Spring的发展 1.1. Spring1.x 时代 在Spring1.x时代,都是通过xml文件配置bean,随着项目的 ...
- 配置NFS共享
NFS(网络文件系统)-------> linux与linux平台 服务器端: 1.安装软件nfs-utils(服务:nfs-server) 2.创建共享目录:mkdir /nfs_dir 3. ...
- Spring中,请求参数处理
Spring中,Controller里,获取请求数据有多种情况 在使用@RequestParam的方式获取请求中的参数时, 如果没有设置required这个属性,或者主动设置为true,则意味着这个参 ...
- has(expr|ele)保留包含特定后代的元素,去掉那些不含有指定后代的元素。
has(expr|ele) 概述 保留包含特定后代的元素,去掉那些不含有指定后代的元素.大理石平台等级 .has()方法将会从给定的jQuery对象中重新创建一组匹配的对象.提供的选择器会一一测试原先 ...
- (十七)线程,connect的第五个参数
采用多线程,将需要处理的后台数据放入子线程,为了能够跨线程调用,一种方法是使用类似线程锁对线程进行保护,另外一种方法使用Qt的信号槽机制.Qt的信号槽机制采用connect函数进行连接,connect ...
- Linux 文件查看
链接:https://www.nowcoder.com/questionTerminal/fb39fbeec71f43a3a16edeb0bc98f4ac 来源:牛客网 /var/log/messag ...