下载信息 [文件大小:2.75 KB 下载次数: 次] |
![]() |
百度地图---->腾讯地图
function txMap(lng,lat){ let pi = 3.14159265358979324 * 3000.0 / 180.0; let x = lng - 0.0065; let y = lat - 0.006; let z = Math.sqrt(x * x + y * y) - 0.00002 * Math.sin(y * pi); let theta = Math.atan2(y, x) - 0.000003 * Math.cos(x * pi); lng = z * Math.cos(theta); lat = z * Math.sin(theta); return { 'lng': lng, 'lat': lat }; }
腾讯地图---->百度地图
function txMap_to_bdMap(lat,lng){ let pi = 3.14159265358979324 * 3000.0 / 180.0; let x = lng; let y = lat; let z =Math.sqrt(x * x + y * y) + 0.00002 * Math.sin(y * pi); let theta = Math.atan2(y, x) + 0.000003 * Math.cos(x * pi); lng = z * Math.cos(theta) + 0.0065; lat = z * Math.sin(theta) + 0.006; return {'lng':lng,'lat':lat}; }
input 事件:
$('#myInput').on('input', function() { console.log('Input value changed:', $(this).val());});
change 事件:
$('#myInput').on('change', function() { console.log('Input value changed:', $(this).val());});
focus 事件:
$('#myInput').on('focus', function() { console.log('Input focused');});
blur 事件:
$('#myInput').on('blur', function() { console.log('Input blurred');});
keydown 事件:
$('#myInput').on('keydown', function(event) { console.log('Key pressed:', event.key);});
keyup 事件:
$('#myInput').on('keyup', function(event) { console.log('Key released:', event.key);});
keypress 事件:
$('#myInput').on('keypress', function(event) { console.log('Character typed:', event.key);});
paste 事件:
$('#myInput').on('paste', function(event) { const pastedText = event.originalEvent.clipboardData.getData('text'); console.log('Pasted text:', pastedText);});
cut 事件:
$('#myInput').on('cut', function() { console.log('Text cut');});
select 事件:
$('#myInput').on('select', function() { const selectedText = $(this).val().substring(this.selectionStart, this.selectionEnd); console.log('Selected text:', selectedText);});
//禁止滚动条滚动 stopScroll:function(){ document.documentElement.style.overflow=‘hidden’; document.body.style.position=‘fixed’; document.body.style.top=‘0px’; document.body.style.width=“100%”; }, //允许滚动条滚动 openScroll:function(){ document.documentElement.style.overflow=‘scroll’; document.body.style.position=‘static’; }
ajax中的回调函数(success等)直接用this不灵,解决办法是使用bind(this)绑定this到当前事件。
$.ajax({type: 'GET', url: "/flag/", data: dat, success:function(){ $(this).prevAll('p').css("text-decoration","line-through"); }.bind(this) });
<script> $(document).ready(function () { $.get("后台接口,返回签名信息", function(obj){ wx.config({ beta: true,// 必须这么写,否则wx.invoke调用形式的jsapi会有问题 debug: false, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。 appId: obj.appId, // 必填,公众号的唯一标识 timestamp: obj.timestamp, // 必填,生成签名的时间戳 <%= Html.Encode(ViewData["timestamp" ]) %> nonceStr: obj.nonceStr, // 必填,生成签名的随机串 signature: obj.signature, // 必填,签名 jsApiList: ['checkJsApi','scanQRCode'] // 必填,需要使用的JS接口列表, 这里只需要调用扫一扫 }); }); wx.ready(function(){ wx.checkJsApi({ //判断当前客户端版本是否支持指定JS接口 jsApiList: ['scanQRCode'], success: function (res) {// 以键值对的形式返回,可用true,不可用false。如:{"checkResult":{"scanQRCode":true},"errMsg":"checkJsApi:ok"} if(res.checkResult.scanQRCode != true){ alert('抱歉,当前客户端版本不支持扫一扫'); } }, fail: function (res) { //检测getNetworkType该功能失败时处理 alert('checkJsApi error'); } }); //wx.checkJsApi结束 // 调起企业微信扫一扫接口 wx.scanQRCode({ desc: 'scanQRCode desc', needResult : 1, // 默认为0,扫描结果由企业微信处理,1则直接返回扫描结果, scanType : [ "qrCode", "barCode" ], // 可以指定扫二维码还是一维码,默认二者都有 success : function(res) { console.log("调用扫描成功",res); var result = res.resultStr; // 当needResult 为 1 时,扫码返回的结果 $("#codeValue").val(result);//显示结果 // alert("扫码结果为:" + result); }, error:function(res){ console.log(res) if (res.errMsg.indexOf('function_not_exist') > 0) { alert('版本过低请升级') } } }); //wx.scanQRcode结束 }); //wx.ready结束 wx.error(function(res){ alert("错误信息:"+JSON.stringify(res)); }); }); //点击按钮进行扫码 $("#scanQRCode").click(function(event){ wx.ready(function(){ wx.scanQRCode({ desc: 'scanQRCode desc', needResult : 1, // 默认为0,扫描结果由企业微信处理,1则直接返回扫描结果, scanType : [ "qrCode", "barCode" ], // 可以指定扫二维码还是一维码,默认二者都有 success : function(res) { console.log("调用扫描成功",res); var result = res.resultStr; // 当needResult 为 1 时,扫码返回的结果 $("#codeValue").val(result);//显示结果 alert("扫码结果为:" + result); }, error:function(res){ console.log(res) if (res.errMsg.indexOf('function_not_exist') > 0) { alert('版本过低请升级') } } }); //wx.scanQRcode结束 }); }); </script>
一、children()
1、描述:获取当前jq对象的子节点
2、语法:jq对象.children()
3、PS:
①当children()不写参数的时候 获取的是所有的孩子
②当children('孩子的选择器') 获取的是指定的孩子
③children() 只能选择 直接孩子 不能选择 孙子元素
4、eg:
$('button:first').click(function () { //选择指定的孩子 $('.box').children('.s1').css('background-color','red'); //选择所有的孩子 $('.box').children().css('background-color','red'); })
二、find()
1、描述:获取指定的孩子
2、语法:jq对象.find('孩子的选择器')
3、PS:
①不能空参使用,不能获取所有的孩子
②只要是孩子元素,就能使用find()
4、eg:
$('button:first').click(function () { console.log('666'); $('.box').find('.s2').css('backgroundColor','red'); });
三、parent()/parents()
1、描述:查找当前jq对象的父节点/所有的父节点直到祖先节点
2、语法:jq对象.parent()/parents()
3、eg:
$('button:first').click(function () { //$('.p0').parent().css('background-color','red'); $('.p0').parents().css('background-color','red'); });
四、siblings()
1、描述:获取所有的兄弟节点
2、语法:jq对象.siblings(选择器)
3、PS:
①不写参数,获取的是所有的兄弟
②写参数,获取的是满足选择器要求的兄弟
4、eg:
$('button:first').click(function () { $('.p0').siblings('.p1').css('background-color', 'red'); }); $('p').click(function () { $(this).html('很开心').siblings().html('很开心').parent().siblings().children().html('不开心'); });
五、next()
1、描述:获取下一个兄弟节点
2、语法:jq对象.next()
3、eg:
$('p').click(function () { $(this).next().css('background-color','red'); })
六、nextAll()
1、描述:获取后面所有的兄弟节点
2、语法:jq对象.nextAll()
3、eg:
$('p').click(function () { $(this).nextAll().css('background-color', 'red'); });
七、prev()
1、描述:获取当前节点的前一个兄弟节点
2、语法:jq对象.prev()
3、eg:
$('p').click(function () { $(this).prev().css('background-color', 'red'); });
八、prevAll()
1、描述:获取当前节点前面的所有兄弟节点
2、语法:jq对象.prevAll()
3、eg:
$('p').click(function () { $(this).prevAll().css('background-color', 'red'); });
if($(":input[name=piclist]").length <= 0){ return false; }
if (!$(":radio[name=sex]").is(":checked")){ alert("请选择性别"); $("#sex").focus(); return false; }
function ISmobile(str){ var p=/^1[3|4|5|6|7|8][0-9]\d{7,8}$/; if(str.match(p)!=null) { return true; } return false; } function IScard(str){ var p=/(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/; if(str.match(p)!=null) { return true; } return false; }