js,jquery 操作 dom

来源:互联网 发布:电影片头制作软件 编辑:程序博客网 时间:2024/06/03 18:06

1.修改页面内容

$("#test").text("你好");

$("#test").html("你好")

2.格式化日期

var odate = new Date();
var mon = parseInt(odate.getMonth())+1
$("#applayDate").html(odate.getFullYear()+"年"+mon+"月"+odate.getDate())+"日";

3.防止重复点击提交按钮
    function timer(btn){
        btn.attr("disabled", true);
        setTimeout(function() {
            btn.attr("disabled", false);
        }, 2000);
    };

4.处理手机号
 js控制手机号码中间用星号代替
var Mobile = localStorage.getItem("Mobile");
var mobile2 = Mobile.substring(0,3)+"****"+Mobile.substring(8,11);
console.log(mobile2);
$('#phone').text(" “ "+mobile2+" ” ");
5.延迟跳转
setTimeout("window.location.href='authorize.html'",2000);

0 0