<script type="text/javascript"> //给身份证文本框添加一个失去焦点事件: $("#idNumber").blur(function() { //获取身份证号码,例如:412702199301010000,这里不再判断身份证号是否合法 var idNumber = $("#idNumber").val(); //定义籍贯、出生日期、性别、年龄等变量 var provinces,province,birthday,currDate,month,date,age,sex; //一、获取籍贯,由于数据量比较大,所以这里只获取到省: //定义地区数组 provinces = { 11: "北京", 12: "天津", 13: "河北", 14: "山西", 15: "内蒙古", 21: "辽宁", 22: "吉林", 23: "黑龙江", 31: "上海", 32: "江苏", 33: "浙江", 34: "安徽", 35: "福建", 36: "江西", 37: "山东", 41: "河南", 42: "湖北", 43: "湖南", 44: "广东", 45: "广西", 46: "海南", 50: "重庆", 51: "四川", 52: "贵州", 53: "云南", 54: "西藏", 61: "陕西", 62: "甘肃", 63: "青海", 64: "宁夏", 65: "新疆", 71: "台湾", 81: "香港", 82: "澳门", 91: "国外" }; province = provinces[parseInt(idNumber.substr(0, 2))]; //二、出生日期 birthday = idNumber.substring(6, 10) + "-" + idNumber.substring(10, 12) + "-" + idNumber.substring(12, 14); //三、计算年龄 currDate = new Date(); month = currDate.getMonth() + 1; date = currDate.getDate(); age = currDate.getFullYear() - idNumber.substring(6, 10) - 1; //判断年龄 if (idNumber.substring(10, 12) < month || (idNumber.substring(10, 12) == month && idNumber.substring(12, 14) <= date)) { age++; } //四、获取性别 if (parseInt(idNumber.substr(16, 1)) % 2 == 1) { //男 sex = "man"; } else { //女 sex = "woman"; } //赋值 $("#province").val(province); $("#birthday").val(birthday); $("#age").val(age); $("input[name='sex'][type=radio][value='" + sex + "']").attr("checked", true); }); </script>
网易云接口
http://ip.ws.126.net/ipquery?ip=[IP地址]
搜狐接口
http://pv.sohu.com/cityjson?ie=utf-8
爱奇艺接口
http://ip.geo.iqiyi.com/cityjson?format=json&ip=[IP地址]
ip-api
http://ip-api.com/json/[IP地址]?lang=zh-CN
太平洋电脑网接口
http://whois.pconline.com.cn/ipJson.jsp?ip=[IP地址]&json=true
腾讯接口
https://apis.map.qq.com/ws/location/v1/ip?output=jsonp&key=KUQBZ-FYDCU-YMVVN-2DDW5-7WDYE-5JBJR&ip=[IP地址]&callback=jQuery18301852690032249129_1600324416562&_=1600324417180
ip.cn
https://www.ip.cn/api/index?ip=&type=0
bilibili
https://api.bilibili.com/x/web-interface/zone
speedtest
https://forge.speedtest.cn/api/location/info
<!--test.wxml-->
<button style="margin-top:50px;" bindtap="getQRCode">扫一扫</button>
<view>{{ qRCodeMsg }}</view>
//test.js Page({ data:{ qRCodeMsg:'' }, getQRCode: function(){ var _this = this; wx.scanCode({ //扫描API success: function(res){ console.log(res); //输出回调信息 _this.setData({ qRCodeMsg: res.result }); wx.showToast({ title: '成功', duration: 2000 }) } }) } })
<p>hello</p>
$("p").append("<b>world</b>")使用append插入
<p>hello<b>world</b></p>//显示结果
$("p").prepend("<b>world</b>")//使用prepend插入
<p><b>world</b>hello</p>//显示结果
$("p").after("<b>world</b>")//使用after插入语句
<p>hello</p><b>world</b>//显示结果
$("p").before("<b>world</b>")//使用before插入语句
<b>world</b><p>hello</p>//显示结果
Math.pow(2,50) // => 2的50次幂 js的幂运算
Math.round(.7) //=> 1.0 js的四舍五入运算
Math.ceil(.6) //=>1.0 向上求整
Math.floor(.8) //=>0 向下求整
Math.abs(-10) //=>10 求绝对值
Math.min(x,y,z) //=>返回最小值
Math.max(x,y,z) //=>返回最大值
Math.random() //=>生成一个大于等于0小于等于1.0的伪随机数
data=data.replace("]","");
<script> $(function(){ var a = 'abcdefg'; var aleng = a.length; if(aleng>5){ a.substring(0,5)+'...'; } }); </script>
<script> $(function() { $("#shouhou2").hide(); $("#shouhou3").hide(); //给div添加change事件 $("#type").change(function() { if($(this).val() == 1 ) { $("#shouhou1").show(); $("#shouhou2").hide(); $("#shouhou3").hide(); } else if($(this).val() == 2 ) { $("#shouhou2").show(); $("#shouhou1").hide(); $("#shouhou3").hide(); } else if($(this).val() == 3 ) { $("#shouhou3").show(); $("#shouhou1").hide(); $("#shouhou2").hide(); } }) }) </script> <select class="select" size="1" name="type" id="type"> <option value="1">表格</option> <option value="2">折线图</option> <option value="3">柱状图</option> </select> <div id="shouhou1" style>表格区域</div> <div id="shouhou2" style>折线图区域</div> <div id="shouhou3" style>柱状图区域</div>
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title></title> </head> <body> <input type="text" name="alertDateQuery" id="aDate"> </body> <script type="text/javascript"> var mydateInput = document.getElementById("aDate"); var date = new Date(); var dateString = date.getFullYear() + "/" + (date.getMonth() + 1) + "/" + date.getDate(); mydateInput.value = dateString; </script> </html>
当背景色不为白色的时候,要给input输入框设置成为白色,一般来说,设置color:#fff即可,但是placeholder默认的文字颜色还是灰色,这个时候需要写代码设置输入框placeholder文字颜色。
找到全局css文件,添加伪类元素,因为直接修改input颜色只作用于输入的文字,并不能改变默认字体的颜色,同时主要是要兼容火狐,IE和谷歌浏览器。
input:-moz-placeholder, textarea:-moz-placeholder { color: #fff; } input:-ms-input-placeholder, textarea:-ms-input-placeholder { color: #fff; } input::-webkit-input-placeholder, textarea::-webkit-input-placeholder { color: #fff ; }