首页 > 其他分享 >jQuery 加入购物车 弹窗

jQuery 加入购物车 弹窗

时间:2023-01-03 15:34:34浏览次数:38  
标签:jQuery 40px none height background 购物车 margin display 弹窗


功能介绍:

1.点击按钮,出现弹窗,和蒙版

2.购物车数量显示1件商品

3.点击右上角关闭按钮,关闭弹窗,蒙版消失

4.点击继续购物按钮,弹窗消失,蒙版消失

5.点击去购物车按钮,跳转页面

6.点击蒙版,弹窗和蒙版都消失

7.再次点击加入购物车,购物车中数量递增

HTML所有代码:

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>弹窗 蒙版 赋值</title>
<style>
body,div,dl,dt,dd,ul,li,h1,h2,h3,h4,h5,h6,code,form,input,textarea,p,th,td,fieldset,legend,figure{
margin:0;
padding:0;
}
body,html{
width: 100%;
}
body{
font-family:"微软雅黑",Arial;
overflow-x:hidden;
}
ul,ol{
list-style:none;
}
a{
text-decoration:none;
}
img{
border:0;
}

.shopcarAdd{
display: block;
background-color: transparent;
outline: none;
width: 150px;
height: 40px;
background: orange;
color: white;
border: none;
text-align: center;
line-height: 40px;
margin:200px auto;
cursor: pointer;
}
.mask{
width: 100%;
height: 100%;
background: black;
opacity: 0.5;
z-index: 2;
position: absolute;
top:0;
display: none;
}
.tanchuang{
width: 500px;
height: 400px;
background-color: white;
position: fixed;
top:50%;
left: 50%;
margin-left: -250px;
margin-top: -200px;
display: none;
z-index: 20;
}
.close{
width: 100%;
height: 40px;
background: #353537;
}
.close span{
display: block;
width:20px;
height: 20px;
background: white;
float: right;
text-align: center;
line-height: 20px;
margin-top: 10px;
margin-right: 10px;
cursor: pointer;
}
.add{
margin-top: 100px;
text-align: center;
}
.add p{
margin-bottom: 10px;
}
.go{
margin-left: 140px;
margin-top: 70px;
}
.go a{
display: block;
width: 100px;
height: 40px;
float: left;
line-height: 40px;
text-align: center;
}
.goOn{
display: block;
width: 100px;
height: 40px;
float: left;
line-height: 40px;
text-align: center;
border: 1px solid #fb9d46;
color: #fb9d46;
margin-right: 20px;
background: white;
cursor: pointer;
}
.go a:last-child{
height: 40px;
background: #fb9d46;
color: white;
}

</style>
</head>
<body>
<button class="shopcarAdd">
加入购入车
</button>
<div class="mask"></div>

<div class="tanchuang">
<div class="close">
<span class="close1">x</span>
</div>
<div class="add">
<p>商品已成功添加到购物车</p>
<p>购物车一共有<span id="mun">0</span>件商品</p>
</div>
<div class="go">
<button class="goOn">继续购物</button>
<a href="http://www.taobao.com">去购物车</a>
</div>
</div>
</body>
</html>
<script src="js/jquery-1.8.3.min.js"></script>
<script>

$(".close1").click(function(){
$(".tanchuang").css("display","none");
$(".mask").css("display","none");
});
$(".goOn").click(function(){
$(".tanchuang").css("display","none");
$(".mask").css("display","none");
});

var nums = 0;
var spans = $("#mun");
$(".shopcarAdd").click(function(){
$(".mask").css("display","block");
$(".tanchuang").css("display","block");
nums = $("#mun").html();
nums++;
spans.html(nums);
});

$(".mask").click(function(){
$(".tanchuang").css("display","none");
$(".mask").css("display","none");
});

</script>

 

 

标签:jQuery,40px,none,height,background,购物车,margin,display,弹窗
From: https://blog.51cto.com/u_12422954/5986026

相关文章

  • 小程序开发总结三 弹窗 动态class 发送请求 设置本地储存过期时间
    弹窗<buttonclass="get_codebindtap="get_login">{{get_code}}</button>get_login(e){wx.showToast({title:'请输入手机号码',icon:'none',......
  • jquery选项卡
    功能介绍:1.鼠标划过当前按钮,当前按钮变色2.对应图片展示3.鼠标划过其他按钮,对应图片出现,其他按钮变回原色,其他图片隐藏所有代码:<!DOCTYPEhtml><htmllang="en"><head><......
  • jquery的each()详细介绍
    each()方法能使DOM循环结构简洁,不容易出错。each()函数封装了十分强大的遍历功能,使用也很方便,它可以遍历一维数组、多维数组、DOM,JSON等等在javaScript开发过程中......
  • jQuery基础知识
    1、jqueryjQuery是一个javaScript第三方模块(第三方类库)。基于jQuery,自己开发一个功能。现成的工具依赖jQuery,例如bootstrap动态效果jQuery手册http://hemin.cn/jq/......
  • jQuery——效果
    方法例句描述animate() 对被选元素应用“自定义”的动画clearQueue() 对被选元素移除所有排队的函数(仍未运行的)delay() 对被选元素的所有排队函数(......
  • 基于jQuery的三种AJAX请求
    基于jQuery的三种AJAX请求1.介绍get请求通常用于获取服务端资源(向服务器要资源)​ 例如:根据URL地址,从服务器获取HTML文件、CSS文件、JS文件、图片文件、数据资源等......
  • python入门 之购物车程序
    #1.启动程序后,让用户输入工资,然后打印商品列表#2.允许用户根据商品编号购买商品#3.用户选择商品后,检查余额是否足够,够就直接扣款,不够就提醒#4.可随时退出,退出时,打印已......
  • 【小程序】微信小程序实现居中弹窗(红包关闭效果)
    一、效果  二、wxss代码<!--弹出红包--><viewwx:if="{{isCloseCenter_1==1}}"class="pop_center_1"><viewclass="PanelCenter_1"><viewclass="PanelCenter1Ro......
  • jQuery.fn.extend() 与 jQuery.extend()
    jQuery.fn如何扩展。jQuery插件$.fn(object)与$.extend(object)jQuery提供了两个方法帮助开发插件$.extend(object);扩展jQuery类本身;$.fn.extend(object);扩展jQuer......
  • WordPress首页弹窗美化
    WrodPress美化:给知更鸟主题添加重要公告首页弹窗提示功能步骤如下:1、代码下载首先下载几个代码文件,分别按要求上传到自己主题的相应目录下:notice.css(上传到你主题CSS目录......