1.不知道为啥用给盒子用display:inline-flex,盒子与盒子之间会有间距;解决:给display:flex,加folat:left,就可以了;但记得要清除浮动哦!
2.自定义验证提示框
function showmsg(msg) {
var htm = '<div class="showmsg"><span>' + msg + '</span></div>';
$(".dialoge").append(htm);
$(".showmsg").fadeIn(100);
setTimeout(function() {
$(".showmsg").fadeOut(100);
}, 1500);
}
css样式就是绝对定位了
3.点击空白处,关闭弹框和遮罩层
$(document).mouseup(function(e) {
var pop = $('.dialoge');
if(!pop.is(e.target) && pop.has(e.target).length === 0) {
$('.mask').hide(); //遮罩层
$('.dialoge').hide(); //弹框
}
});
4.遮罩层
$(".mask").css("height", $(document).height());//让遮罩层和屏幕一样高
$(".mask").css("width", $(document).width());//让遮罩层和屏幕一样宽
.mask{
position: absolute;
background: rgba(0,0,0,0.5);
left:0;
top:0;
right:0;
z-index:2;
display: none;
}
5.数量加减
$("#buynum_jia").on('click', function () {
BuyNumChange(1);
});
$("#buynum_jian").click(function () {
BuyNumChange(-1);
});
function BuyNumChange(num) {
var cur = $("#sel_num").val();
var cur_p = parseInt(cur);
if (isNaN(cur_p))
cur_p = _minnum;
if (cur_p + num < _minnum)
$("#sel_num").val(_minnum);
else
$("#sel_num").val(cur_p + num);
}
网友评论