//询盘 $(function () { $('#xunpantext').hover(function () { var xunpantext = $(this).data('tiptitle'); $('#xunpantip').text(xunpantext) $('#xunpantip').addclass('xunpantextactive') }, function () { $('#xunpantip').removeclass('xunpantextactive') }) }) $(function () { var stop = 0; var x = $("#fixednav").offset().top; $(window).scroll(function () { stop = $(this).scrolltop(); if (stop >= x) { $("#fixednav").addclass("fixednav"); } else { $("#fixednav").removeclass("fixednav"); } }); }); $(function () { $('.button').html((i, html) => { return '' + $.trim(html).split('').join('') + ''; }); }); // 重复内容 // $('.menu>ul>li>a').each(function (i,btn) { // var $t = $(btn); // var $btntext = $t.html(); // var $splittext = $btntext.split(""); // $t.html("").append(""+$btntext+""+""+$btntext+""); // }) //导航 $(function () { $('.nlayer2').each(function () { $(this).find('a:gt(5)').remove(); }) // $('.secs').each(function () { // $(this).find('li.nlayer1:gt(5)').remove(); // }) // 无三级菜单时不显示背景 $('.nlayer2').each(function () { if($(this).children().length <= 0){ $(this).css({ "display": "none", }) } $(this).before("
"); $(this).after("
"); }) $('.menu>ul > li').hover(function () { $(this).find('.secs').slidedown(400); if($(this).find('.sec').children().length>0){ $(this).find('.sec').slidedown(400); } }, function () { $(this).find('.sec').stop().slideup(400); $(this).find('.secs').stop().slideup(400); }); // 搜索 $('.searchico .hide').click(function(){ $(".searchbox").removeclass("searchshow"); $(".searchico").removeclass("top"); }); $('.searchico .show').click(function(){ $(".searchbox").addclass("searchshow"); $(".searchico").addclass("top"); }); $('.searchico .hide').click(function(){ $(".searchbox").removeclass("searchshow"); $(".searchico").removeclass("top"); }); $('.linkbox dt i').click(function(){ $(".linkbox dd").slidetoggle(500); }); $(".fhbtn").click(function(){ $('body,html').animate({scrolltop:0},1500); return false; }); }) //提交 $(function () { $('.submitform').on('click', function () { var kcontent = $('.xqcontent').val(); var kuser = $('.username').val(); var kphone = $('.usertel').val(); // var kadd = $('.useradd').val(); var kcode = $('.codetext').val().trim(); // var kemail = $('.useremail').val(); var reg = /(^(0[0-9]{2,3}\-)?([2-9][0-9]{6,7})+(\-[0-9]{1,4})?$)|(^((\(\d{3}\))|(\d{3}\-))?(1[3578]\d{9})$)|(^400[0-9]{7})/; if (kuser == "") { alert('姓名不能为空!') $(".username").focus(); return false; } if (kphone == "") { alert('号码不能为空!') $(".usertel").focus(); return false; } if(!reg.test(kphone)) { alert('号码填写有误!') $(".usertel").focus(); return false; } if (kcontent == "" || kcontent.length < 10) { alert('留言内容必须大于10字!') $(".xqcontent").focus(); return false; } if (kcode == "") { alert('验证码不能为空') $(".codetext").focus(); return false; } $.post('/api/message.ashx?action=add', { // "kcontent": '邮箱:' + kemail + '留言:' + kcontent , "kcontent": '留言:' + kcontent , "kuser": kuser, "kphone": kphone, "kcode": kcode }, function (res) { if (res == 1) { alert("留言提交成功"); $('.xqcontent').val(''); $('.username').val(''); $('.usertel').val(''); $('.usermail').val(''); $('.codetext').val(''); }else { alert("留言提交失败") } }) }) //验证码刷新 $(".imgcode").click(function () { $(".imgcode")[0].src = '/api/message.ashx?action=code&' + math.random() }); //重置 $(".czform").click(function () { $('.xqcontent').val(''); $('.username').val(''); $('.usertel').val(''); $('.codetext').val(''); }); })