赞
踩
<!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) } //字符串的截取 1:通过下标的方法 var cookie = "hfhsfhsfhshHUIHHHHuhhghgihdHUHHUYGUHIhhf;shush=sfsdgsgsbsbsbsufus;" /* var Oindex = cookie.indexOf('shush') var firstindex = Oindex+'shush'.length+1 var secondindex = cookie.indexOf(';',firstindex) console.log(firstindex,secondindex) var val = cookie.slice(firstindex,secondindex) console.log(val) */ // 2:字符串的分割 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]) } } // 电话号码的隐藏 1:截取 var phonenumble = '13355666208' /* var newphonenumble = phonenumble.slice(0,3)+'****'+phonenumble.slice(7) console.log(newphonenumble) */ // 2:替换 var newphonenumble2 = phonenumble.replace(/^(\d{3})\d{4}(\d+)/,'$1****$2') console.log(newphonenumble2) </script> </html>
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。