jquery 蔚蓝网

$(document).ready(function(){
    //提交表单
    $("#registerBtn").click(function(){
        var email=document.getElementById("email");
        if(email.validity.valueMissing==true){
            email.setCustomValidity("邮箱不能为空");
        }
        else if(email.validity.typeMismatch==true){
            email.setCustomValidity("邮箱格式不正确,例如web@bdqn.cn");
        }
        else{
            email.setCustomValidity("");
        }

        var uName=document.getElementById("nickName");
        if(uName.validity.valueMissing==true){
            uName.setCustomValidity("昵称不能为空");
        }
        else if(uName.validity.patternMismatch==true){
            uName.setCustomValidity("昵称必须是4~20位的英文和数字");
        }
        else{
            uName.setCustomValidity("");
        }
        var pwd=document.getElementById("pwd");
        if(pwd.validity.valueMissing==true){
            pwd.setCustomValidity("密码不能为空");
        }
        else if(pwd.validity.patternMismatch==true){
            pwd.setCustomValidity("密码必须是6~20位的英文和数字");
        }
        else{
            pwd.setCustomValidity("");
        }
        var repwd=document.getElementById("repwd");
        if(repwd.val()==pwd.val()){ repwd.setCustomValidity("");}
        else{repwd.setCustomValidity("两次输入的密码不一致");}


    });
    //提交按钮样式变化
    $("#registerBtn").mouseover(function(){
        $(this).attr("src","images/register_btn_over.gif");
    }).mouseout(function(){
        $(this).attr("src","images/register_btn_out.gif");
    });
    //省市级联
    var cityList = new Array();
    cityList['北京市'] = ['朝阳区','东城区','西城区', '海淀区','宣武区','丰台区','怀柔','延庆','房山'];
    cityList['上海市'] = ['宝山区','长宁区','丰贤区', '虹口区','黄浦区','青浦区','南汇区','徐汇区','卢湾区'];
    cityList['广州省'] = ['广州市','惠州市','汕头市','珠海市','佛山市','中山市','东莞市'];
    cityList['深圳市'] = ['福田区', '罗湖区', '盐田区', '宝安区', '龙岗区', '南山区', '深圳周边'];
    cityList['重庆市'] = ['俞中区', '南岸区', '江北区', '沙坪坝区', '九龙坡区', '渝北区', '大渡口区', '北碚区'];
    cityList['天津市'] = ['和平区', '河西区', '南开区', '河北区', '河东区', '红桥区', '塘古区', '开发区'];
    cityList['江苏省'] = ['南京市','苏州市','无锡市'];
    cityList['浙江省'] = ['杭州市','宁波市','温州市'];
    cityList['四川省'] = ['四川省','成都市'];
    cityList['海南省'] = ['海口市'];
    cityList['福建省'] = ['福州市','厦门市','泉州市','漳州市'];
    cityList['山东省'] = ['济南市','青岛市','烟台市'];
    cityList['江西省'] = ['江西省','南昌市'];
    cityList['广西省'] = ['柳州市','南宁市'];
    cityList['安徽省'] = ['安徽省','合肥市'];
    cityList['河北省'] = ['邯郸市','石家庄市'];
    cityList['河南省'] = ['郑州市','洛阳市'];
    cityList['湖北省'] = ['武汉市','宜昌市'];
    cityList['湖南省'] = ['湖南省','长沙市'];
    cityList['陕西省'] = ['陕西省','西安市'];
    cityList['山西省'] = ['山西省','太原市'];
    cityList['黑龙江省'] = ['黑龙江省','哈尔滨市'];
    cityList['其他'] = ['其他'];
    $("#province").append(function(){
        var html="";
        for (var i in cityList){
            html+="<option value="+i+">"+i+"</option>";
        }
        return $(html);
    });
    $("#province").change(function(){
        var v= $(this).val();
        var html="";
        if(v=="请选择省/城市"){
            html="<option>请选择城市/地区</option>";
            $("#city").html(html);
            return;
        }
        var citys=cityList[v];
        $.each(citys,function(i,n){
            html+="<option value="+n+">"+n+"</option>";
        });
        $("#city").html(html);
    });
});

 

$(function($){
    //打开一个广告窗口
   window.open('open.html','','top=0,left=200,width=500,height=327,scrollbars=0,resizable=0');
    //随滚动条滚动的可关闭广告窗口
    $(window).scroll(function(){
        var st = $(this).scrollTop()+50;
        $("#right").css("top",st);
    });
    $("#right").find("a").click(function(){
        $("#right").hide();
    });
    //轮换图片
    function changeImg(){
        var index=0;
        var stop=false;
        var $li=$("#content").find("#scroll_img").children("li");
        var $page = $("#content").find("#scroll_number").children("li");
        $page.eq(index).addClass("scroll_number_over").stop(true,true).siblings().removeClass("scroll_number_over");
        $page.mouseover(function(){
            stop=true;
            index=$page.index($(this));
            $li.eq(index).stop(true,true).fadeIn().siblings().fadeOut();
            $(this).addClass("scroll_number_over").stop(true,true).siblings().removeClass("scroll_number_over");
        }).mouseout(function(){
            stop=false;
        });
        setInterval(function(){
            if(stop) return;
            index++;
            if(index>=$li.length){
                index=0;
            }
            $li.eq(index).stop(true,true).fadeIn().siblings().fadeOut();
            $page.eq(index).addClass("scroll_number_over").stop(true,true).siblings().removeClass("scroll_number_over");
        },3000);
    }
    changeImg();

    $(".book ul img").mouseenter(function(){
        $(this).animate({width:"110%"},"slow");
    });
    $(".book ul img").mouseleave(function(){
        $(this).animate({width:"80%"},"slow");
    });

    //图书畅销榜切换
    $(".tab ol li:first-of-type").mouseover(function(){
        $(".tab ol li:last-of-type").css({"background":"#efefef","border-left":"1px solid #cccccc","border-bottom":"1px solid #ccc","width":"118px"});
        $(this).css({"width":"119px","background":"#ffffff","border":"none"});
        $(".tab ul:first-of-type").show();
        $(".tab ul:last-of-type").hide();
    });
    $(".tab ol li:last-of-type").mouseover(function(){
        $(".tab ol li:first-of-type").css({"background":"#efefef","border-right":"1px solid #cccccc","border-bottom":"1px solid #ccc","width":"118px"});
        $(this).css({"width":"119px","background":"#ffffff","border":"none"});
        $(".tab ul:first-of-type").hide();
        $(".tab ul:last-of-type").show();
    });
    $(".tab ul li p").mouseenter(function(){
        $(this).next().show();
        $(this).hide();
        $(this).parent().siblings().children("p").show().end().children("dl").hide();
    })
    //书讯快递循环垂直向上滚动
    function movedome(){
        var marginTop=0;
        var stop=false;
        var interval=setInterval(function(){
            if(stop) return;
            //children子代选择器 匹配到之后的所有li  first第一个    marginTop          0代表
            $("#express").children("li").first().animate({"margin-top":marginTop--},0,function(){
                var $first=$(this);
                if(!$first.is(":animated")){
                    if((-marginTop)>$first.height()){
                        $first.css({"margin-top":0}).appendTo($("#express"));
                        marginTop=0;
                    }
                }
            });
        },50);
        $("#express").mouseover(function(){
            stop=true;
        }).mouseout(function(){
            stop=false;
        });
    }
    movedome();
});

$(function($){
    //图书分类动态展示
    function productList(){
        var list=new Array(
            "中国当代小说(13880)","中国近现代小...(640)","中国古典小说(1547)",
            "四大名著(696)","港澳台小说(838)","外国小说(5119)",
            "侦探/悬疑/推...(2519)","惊悚/恐怖(798)","魔幻(369)","科幻 (513)",
            "武侠(574)","军事(726)","情感 (6700)",
            "社会(4855)","都市(949)","乡土(99)","职场(176)",
            "财经(292)","官场(438)","历史(1329)","影视小说(501)",
            "作品集(2019)","世界名著(3273)"
        );
        var html=[];
        $.each(list, function(i, n){
            html.push("<li> ·<a href='#' class='blue'>"+n+"</a></li>");
        });
        $("#product_catList_class").html(html.join(""));
    }
    productList();
    //图书动态展示
    function bookList(){
        var catalog=new Array();
        catalog[0] = ['product_list_01.jpg','私募(首部披露资本博弈秘密的金融小说)',4,'郭现杰','花山文艺出版社', '2009年08月',
            '数年前,在一次股市的多、空之战中,以赵云狄、林康为首的私募基金—金鼎投资,和以王雨龙为首的私募基金,达成锁仓协议分食利益。殊料,以王雨龙为首的私募基金—鑫利投资背信弃义,导致金鼎投资惨败。以至...',
            '13.10','59折','¥18.90','¥32.00'];
        catalog[1] = ['product_list_02.jpg','圈子圈套.1.战局篇',4,'王强','清华大学出版社', '2006年01月',
            '虽然没有硝烟,却比战场更血腥;虽然并未战死,却比死亡更痛苦。 洪钧从一个底层的销售人员,成为一家著名的跨国公司的中国区代理首席代表,在即将被扶正,事业情感都志得意满的时候,掉入俞威设计的圈套,...',
            '¥8.90','68折','¥19.10','¥28.00'];
        var html="";
        $.each(catalog,function(i,n){
            html+="<div class='product_storyList_content_left'><img src=images/"+n[0]+" alt='图书列表'></div>";
            html+="<div class='product_storyList_content_right'><ul>";
            html+="<li class='product_storyList_content_dash'><a href='#' class='blue_14'>"+n[1]+"</a></li>";
            html+="<li>顾客评分:";
            for(var k=0;k<5;k++){
                if(k<n[2]){
                    html+= "<img src='images/star_red.gif' alt='star'>";
                }
                else{
                    html+= "<img src='images/star_gray.gif' alt='star'>";
                }
            }
            html+="</li>";
            html+="<li>作 者:<a href='#' class='blue_14'>"+n[3]+"</a> 著</li>";
            html+="<li>出版社:<a href='#' class='blue_14'>"+n[4]+"</a></li>";
            html+="<li>出版时间:"+n[5]+"</li>";
            html+="<li>"+n[6]+"</li>";
            html+="<li> <dl class='product_content_dd'>";
            html+="<dd><img src='images/product_buy_02.gif' alt='shopping'></dd>";
            html+="<dd><img src='images/product_buy_01.gif' alt='shopping'></dd>";
            html+="<dd>节省:"+n[7]+"</dd>";
            html+="<dd>折扣:<span>"+n[8]+"</span></dd>";
            html+="<dd class='footer_dull_red'><span>"+n[9]+"</span></dd>";
            html+="<dd class='product_content_delete'><span>"+n[10]+"</span></dd>";
            html+="</dl></li></ul></div>";
            html+="<div class='product_storyList_content_bottom'></div>";
        });
        $("#storyBooksssss").html(html);
    }
    bookList();
    //获取列表形式List,默认是列表形式,因此先取得列表形式的内容
    var arrayBookList=$("#product_storyList_content").html();
    //获取大图形式List
    function getBigBookList(){
        var $initContent=$("#product_storyList_content");
        var $bookImg = $initContent.find(".product_storyList_content_left");
        var contents="";
        $initContent.find(".product_storyList_content_right").find("ul").each(function(i,ele){
            var div="";
            var content=[div,"<div class='big_img_list'><ul><li class='bookImg'>"+$($bookImg[i]).html()+"</li>"];
            var $li=$(ele).children("li");
            var $price=$($li[6]).find("span");
            content.push("<li><dl><dd class='footer_dull_red'>"
                +$($price[1]).text()+"</dd><dd class='product_content_delete'>"
                +$($price[2]).text()+"</dd><dd class='footer_dull_red'>"
                +$($price[0]).text()+"</dd></dl></li>");//价格
            content.push("<li class='detail'>"+$($li[5]).html()+"</li>");//简介
            content.push("<li class='detail'>"+$($li[2]).html()+"</li>");//作 者
            content.push("<li class='detail'>"+$($li[1]).html()+"</li>");//顾客评分
            content.push("<li class='detail'>"+$($li[3]).html()+"</li>");//出版社
            content.push("<li class='detail'>"+$($li[4]).html()+"</li></ul></div>");//出版时间
            contents+=content.join("");
        });
        return contents;
    }
    var bigBookList=getBigBookList();//获取大图形式List
    //大图列表切换
    $("#product_array").children("a").click(function(){
        if($(this).is("[class='click']")) return;//如果已经点击那么返回,用class来判断
        $(this).siblings().removeClass("click");
        $(this).addClass("click");
        //用元素的name来判断
        if($(this).attr("name")=="array"){//列表
            $("#product_storyList_content").empty().html(arrayBookList);
        }else{//大图
            $("#product_storyList_content").empty().html(bigBookList);
            $("#product_storyList_content").children(".big_img_list").find("ul").mouseover(function(){
                $(this).addClass("over");
                $(this).parent().addClass("over");
            }).mouseout(function(){
                $(this).removeClass("over");
                    $(this).parent().removeClass("over");
            });
        }
    });
});

$(function($){
    //根据您挑选的商品,当当为您推荐部分的显示和隐藏
    $("#shopping_commend_arrow").click(function(){
        if($("#shopping_commend_sort").css("display")=="none"){
            $(this).attr("src","images/shopping_arrow_up.gif");
        }else{
            $(this).attr("src","images/shopping_arrow_down.gif");
        }
        $("#shopping_commend_sort").toggle();
    });
    //商品隔行变色
    $("#myTableProduct").find("tr:odd").css("backgroundColor","#ffebcd");
    //商品变色
    $("#myTableProduct").find("tr").mouseover(function(){
        $(this).css("backgroundColor","#fff");
    }).mouseout(function(){
        if($("#myTableProduct").find("tr").index($(this))%2==1) {//判断是否奇数行
            $(this).css("backgroundColor","#ffebcd");
        }else{
            $(this).css("backgroundColor","#fefbf2");
        }
    });
    //计算总价
    function totalPrice(){
        var percents= 0,prePrices= 0,prices=0;//积分,原价,现价
        $("#myTableProduct").find("tr").each(function(i,ele){
            var num=$(ele).find(".shopping_product_list_5").find("input").val();//数量
            percents+=parseInt($(ele).find(".shopping_product_list_2").text())*num;
            //解决下js中浮点数的bug问题,因此建议浮点数的运算不要放在前台,这里是指粗略的解决了一下
            var price=parseInt($(ele).find(".shopping_product_list_4").find("label").text().replace(".",""))*num;
            prices+=price;
            var prePrice=parseInt($(ele).find(".shopping_product_list_3").find("label").text().replace(".",""))*num;
            prePrices+=prePrice;
        });
        $("#product_integral").text(percents);
        $("#product_total").text(prices/100);
        $("#product_save").text((prePrices-prices)/100);
        return prices/100;
    }
    totalPrice();
    //删除商品
    $("#myTableProduct").find(".shopping_product_list_6").children("a").click(function(){
        if(confirm("您确定要删除商品么?")){
            $(this).parent().parent().remove();
            totalPrice();
        }
    });
    //修改数量
    $("#myTableProduct").find(".shopping_product_list_5").children("input").change(function(){
        var value=$(this).val();
        if((value == "")||!(/^[0-9]*[1-9][0-9]*$/.test(value))){
            alert("数量不能为空,且只能为正整数");
            $(this).val(1);
        }
        var t =totalPrice();
        alert("修改成功!,您的商品总金额是"+t+"");
    });
    //清空购物车
    $("#removeAllProduct").click(function(){
        //注意清除的先后顺序
        $("#myTableProduct").next().remove();
        $("#myTableProduct").remove();
        $(".shopping_list_border").append("<div class='empty_product'><div>您还没有挑选商品,<a href='index.html'>去挑选看看>></a></div></div>");

    });
});

 

转载于:https://www.cnblogs.com/BaoWangZe/p/9328461.html

  • 3
    点赞
  • 21
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
<html lang="en"> <head> <meta charset="UTF-8"> <title>蔚蓝网首页</title> <link href="css/global.css" rel="stylesheet"/> <link href="css/layout.css" rel="stylesheet"/> <link href="css/template.css" rel="stylesheet" /> </head> <body> <!--随滚动条滚动可关闭广告--> 关闭 <!--头部--> <header id="header"> 您好!欢迎光临蔚蓝网 [登录 | 免费注册] 客户服务 | 新手入门 购物保障 购物流程 会员介绍 常见问题 | 礼品卡 | 我的订单 | 我的账户 | 购物车 </header> <input type="text" placeholder="请输入搜索关键字"><input type="button"> 全部商品分类 首页 图书 特价 团购 <!--网站中间内容开始--> <!--左侧菜单开始--> <!--图书商品分类开始--> 图书商品分类 悬疑 | 言情 | 职场 | 财经 文学 | 传记 | 艺术 | 摄影 青春文学 | 动漫 | 幽默 修养 | 成功 | 职场 | 沟通 0-2 | 3-6 | 7-10 | 11-14文学 | 科普 | 图画书 教材 | 中小学教辅 | 外语 <!--保健 | 家教 | 美丽装扮 | 育儿 | 美食 | 旅游 | 收藏 | 生活 | 体育 | 地图 | 个人理财 [个人社科] 文化 | 历史 | 哲学/宗教 | 古籍 | 政治/历史 | 法律 | 经济 | 社会科学 | 心理学 [管理] 管理 | 金融 | 营销 | 会计 [科技] 科普 | 建筑 | 医学 | 计算机 | 农林 | 自然科学 | 工业 | 通信 [教育] [工具书] [图外原版书] [期刊] --> <!--图书商品分类结束--> <!--左侧菜单结束--> <!--中间部分开始--> <!--轮换显示的横幅广告图片--> 0 1 2 3 4 <!--中间部分结束--> <!--右侧部分开始--> <!--书讯快递--> 书讯快递 ・2010考研英语大纲到货75折... ・权威定本四大名著(人民文... ・口述历史权威唐德刚先生国... ・袁伟民与体坛风云:实话实... ・我们台湾这些年:轰动两岸... ・畅销教辅推荐:精品套书50... ・2010版法律硕士联考大纲75... ・计算机新书畅销书75折抢购 ・2009年孩子最喜欢的书>> ・弗洛伊德作品精选集59折 ・2010考研英语大纲到货75折... ・权威定本四大名著(人民文... ・口述历史权威唐德刚先生国... ・袁伟民与体坛风云:实话实... ・我们台湾这些年:轰动两岸... ・畅销教辅推荐:精品套书50... ・2010版法律硕士联考大纲75... ・计算机新书畅销书75折抢购 ・2009年孩子最喜欢的书>> ・弗洛伊德作品精选集59折 ・2010考研英语大纲到货75折... ・权威定本四大名著(人民文... ・口述历史权威唐德刚先生国... ・袁伟民与体坛风云:实话实... ・我们台湾这些年:轰动两岸... ・畅销教辅推荐:精品套书50... ・2010版法律硕士联考大纲75... ・计算机新书畅销书75折抢购 ・2009年孩子最喜欢的书>> ・弗洛伊德作品精选集59折 ・2010考研英语大纲到货75折... ・权威定本四大名著(人民文... ・口述历史权威唐德刚先生国... ・袁伟民与体坛风云:实话实... ・我们台湾这些年:轰动两岸... ・畅销教辅推荐:精品套书50... ・2010版法律硕士联考大纲75... ・计算机新书畅销书75折抢购 ・2009年孩子最喜欢的书>> ・弗洛伊德作品精选集59折 <!--右侧部分结束--> 电子书 图书畅销榜 图书上新书榜 1追风筝的人追风筝的人中文版,快乐大本营高圆圆感动推荐,奥巴马送给女儿的新年礼物 2解忧杂货店解忧杂货店《白夜行》后东野圭吾备受欢迎作品:不是推理小说,却更扣人心弦 3天才在左疯子在右天才在左疯子在右新增10个被封杀篇章!看高智商疯子如何调戏和羞辱正常人!继高圆圆后,女神陈乔恩芒果台盛情推荐! 4白夜行白夜行东野圭吾推理小说无冕之王。全新精装典藏版 5阮/陈恩静 吕亦涵 著阮/陈恩静 吕亦涵 著商战风云诡谲X情场暗潮汹涌。这一生幸运的是—— 以你之名,冠我之姓 6摆渡人摆渡人畅销欧美33个国家,荣获多项图书大奖。如果命运是一条孤独的河流,谁会是你灵魂的摆渡人?如果我真的存在,也是因为你需要我。 7岛上书店岛上书店每个人的生命中,都有无比艰难的那一年,将人生变得美好而辽阔 8百年孤独百年孤独加西亚马尔克斯代表作,中文版首次授权! 9我们仨我们仨《我们仨》是杨绛先生撰写的家庭生活回忆录,三联书店出版,影响几代人的作品,杨绛先生经典散文! 10从你的全世界路过从你的全世界路过从你的全世界路过 2014中国好书榜获奖图书 1好吗好的好吗好的凡8月12日20:00前下单顾客,100%有大冰亲笔签名,之后下单顾客先到先得签名。各仓到货时间不一致,请各位耐心等待。 2永无止尽的约会永无止尽的约会永无止尽的约会 3你的坚持,终将美好你的坚持,终将美好无论正在经历什么,都请你不要轻言放弃,因为从来没有一种坚持会被辜负 4茧茧阔别十年,张悦然与我们再度重逢。真正的爱,是知道爱你有多困难还选择爱你;真正的长大,是知道生活的真相还热爱生活 5就喜欢你看不惯我 就喜欢你看不惯我 霸气吾皇率蠢萌巴扎黑、伪深邃的牛能强势归来! 6遇见美好系列遇见美好系列全8册,3-7岁心灵成长绘本。 7八万四千问八万四千问宗萨蒋扬钦哲仁波切四年来首部作品:“佛法能够解决你们的所有问题。 8极简生活:简而美地活极简生活:简而美地活极简是风靡全球的一种生活态度与理念。告别繁杂,拥有简而美的生活。 9好妈妈胜过好老师好妈妈胜过好老师好妈妈胜过好老师2:自由的孩子最自觉 10我们始终独自行走在这个世界我们始终独自行走在这个世界十点读书、二更食堂、清华南都等各大微信阅读平台,简书、豆瓣千万读者口碑相传作品。 <!--网站版权部分开始--> 正版保障 | 满额免运 | 货到付款 | 品种最全 | 免费退换 Copyright (C) 蔚蓝网 2006-2016, All Rights Reserved 京ICP证100488号 出版物经营许可证 京批100160号 [removed][removed] [removed][removed] [removed][removed] </body> </html>
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值