html中字符串的获取几种方法
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style >
.layout{
position: absolute;
top: 0;
width: 100%;
height: 100%;
background-color: rgba(0,0,0,0.2);
}
.layout .loginModel{
width:360px;
padding-bottom: 30px;
margin: 200px auto 0;
background-color: #fff;
}
.close{
float: right;
margin-right: 18px;
margin-top: 12px;
width: 16px;
height: 16px;
border: 1px solid #000;
background-image:url(image/pass_login_icons.png);
background-repeat: no-repeat;
background-position: -55px -48px;
cursor: pointer;
}
.close:hover{
background-position: -71px -48px;
}
.loginTitle{
margin-left: 117px;
display: inline-block;
margin-top: 10px;
}
.loginModel input{
width: 300px;
height: 40px;
display: block;
margin: 18px auto 0;
}
#loginbtn{
border: none;
width: 300px;
height: 40px;
display: block;
margin: 18px auto 0;
background-color: #3F89EC;
color: #fff;
font-size: 16px bold;
}
</style>
</head>
<body>
<a href="javascript:;" id="btn">登录</a>
<div class="layout">
<div class="loginModel">
<p><span class="loginTitle">用户名通行证登录</span><span class="close"></span></p>
<input type="text" id="username" placeholder="访客名:输入游客">
<input type="password" id="userpwd" placeholder="通行码:8848">
<button id="loginbtn">进入</button>
</div>
</div>
</body>
<script>
var loginbtn = document.getElementById('loginbtn')
var username = document.getElementById('username')
var userpwd = document.getElementById('userpwd')
loginbtn.onclick = function(){
var username_val = username.value
var userpwd_val = userpwd.value
var str = ''
str = 'username =' +username_val+'&'+'userpwd='+userpwd_val
console.log(str)
}
var cookie = "hfhsfhsfhshHUIHHHHuhhghgihdHUHHUYGUHIhhf;shush=sfsdgsgsbsbsbsufus;"
var arr = cookie.split(';')
console.log(arr)
for (var i = 0;i<arr.length; i++) {
var arr2 = arr[i].split('=')
if (arr2[0].trim() =='shush') {
console.log(arr2[1])
}
}
var phonenumble = '13355666208'
var newphonenumble2 = phonenumble.replace(/^(\d{3})\d{4}(\d+)/,'$1****$2')
console.log(newphonenumble2)
</script>
</html>