````````````````````````````````````````````````````````````````````````````````````` 点击第一个显示第一个 $(document).ready(function() { $('.seaon_nr').hide(); $('.seaon_nr').first().show(); }); $('.seaon .container .box .seaon_nav a').click(function(){ $('.seaon .container .box .seaon_nav a').removeClass('on'); $(this).addClass('on'); let index = $(this).index(); $('.seaon_nr').hide(); $(".seaon_nr").eq(index).show(); }) ````````````````````````````````````````````````````````````````````````````````````` 显示指定数量的标签 $(document).ready(function() { $('div').hide(); // 首先隐藏所有的div元素 $('div:lt(6)').show(); // 显示前六个div元素 }); ````````````````````````````````````````````````````````````````````````````````````` ````````````````````````````````````````````````````````````````````````````````````` 正则匹配 手机 var phoneRegex = /^(?:\+?86)?1[3-9]\d{9}$/; 国内 var phoneRegex = /^\+?[0-9]{1,3}-?[0-9]{3,14}$/; 国际 if (!phoneRegex.test(phone)) { layer.msg("请输入正确的手机号"); return false; } ````````````````````````````````````````````````````````````````````````````````````` url改变 history.pushState(state, "", url); $('.a:eq(1)') ````````````````````````````````````````````````````````````````````````````````````` 删除数组中某个值 var array = [1, 2, 3, 4, 5]; var valueToRemove = 3; array = $.grep(array, function(element){ return element !== valueToRemove; }); ````````````````````````````````````````````````````````````````````````````````````` $(".customizabox-sec1 .cont .fzjut .fz_are1 .item").click(function(){ $(this).toggleClass("on"); on = $(".customizabox-sec1 .cont .fzjut .fz_are1 .on"); all = 0; on.each(function() { num = $(this).find('.wxk').text(); all += num*1; }); $(".xk_all").text(all.toFixed(2)); //四舍五入保留小数 }); ````````````````````````````````````````````````````````````````````````````````````` $(".areAlt .bag,.areAlt .bag,.areAlt .cont .f_but .but1,.areAlt .bag,.areAlt .bag,.areAlt .cont .f_but .but2").click(function(){ var $parentDiv = $(this).closest('.areAlt'); a = $parentDiv.find('.xkw').val(); b = $parentDiv.find('.xkh').val(); c = $parentDiv.find('.xkm').val(); tm = '/'; if(b != 0 && b!= ''){ tm += b+' hours '; } if(c != 0 &&c != ''){ tm += c+' minuts '; } title = $(this).parent().parent().parent().data('title') $(".f_edit[data-title='" + title + "']").closest('.item').find('.text').html(''); $(".f_edit[data-title='" + title + "']").closest('.item').find('.text').html(''+a+'W'+tm+'/day'); $(".areAlt[data-title='" + title + "']").fadeOut(); });