手机号不让显示全
var phone='13123456789'
var showPhone = phone.substr(0,3)+'****'+phone.substr(7);
显示倒计时
var intDiff = parseInt(19000);//倒计时总秒数
function timer(intDiff) {
window.setInterval(function () {
var day = 0,
hour = 0,
minute = 0,
second = 0;
if (intDiff > 0) {
day = Math.floor(intDiff / (60 * 60 * 24));
hour = Math.floor(intDiff / (60 * 60)) - (day * 24);
minute = Math.floor(intDiff / 60) - (day * 24 * 60) - (hour * 60);
second = Math.floor(intDiff) - (day * 24 * 60 * 60) - (hour * 60 * 60) - (minute * 60);
}
if (minute <= 9) minute = '0' + minute;
if (second <= 9) second = '0' + second;
$('#day_show').html(day);
$('#hour_show').html(hour);
$('#minute_show').html(minute);
$('#second_show').html(second);
intDiff--;
}, 1000);
}
$(function () {
timer(intDiff);
});
链接截取某个值
function getid() {
let url = window.location.href
let index = url.indexOf('callback')
if (index != -1) {
let param = url.split("callback=")[1]
if(param.indexOf('&')!=-1){
let jg=param.split("&")[0]
temp = jg
}else{
temp = param
}
}
console.log(temp)
}
支付宝跳转
$.ajax({
type: "POST",
url: $.url+"api/aliPay/pcPay",
data: {
remark:remark,
money:money,
orderNo:orderNo,
goodsType:"2"
},
success: function(r){
console.log(r)
const div = document.createElement('div');
div.innerHTML = r
document.body.appendChild(div);
document.forms[0].submit();
}
});
去除br和空格
wipeBr(data){
return data.replace(/\s*/g,"").replace(/<br\s*.?>/ig,'\n')
}
选项卡
$(".JJFS li").each(function (index) {
$(this).click(function () {
$(this).addClass("pd_sx_xz").siblings().removeClass("pd_sx_xz")
$(".JJ").eq(index).show().siblings(".JJ").hide();
})
})
上下轮播(还需要引入轮播js)
$('#gundon').slide({mainCell:"#gundonbox ul",autoPlay:true,effect:"topMarquee",vis:6,interTime:30});
页面当中打开一个新的浏览器
window.open(
'要跳转的链接',
"mywindow1",
"width=800, height=600, menubar=no, toolbar=no, scrollbars=yes"
);