$("#msgcontent").val().replace(/(\r\n|\n|\r)/gm,'')
选择器 | 实例 | 选取 |
---|---|---|
* | $("*") | 所有元素 |
#id | $("#lastname") | id="lastname" 的元素 |
.class | $(".intro") | 所有 class="intro" 的元素 |
element | $("p") | 所有 <p> 元素 |
.class.class | $(".intro.demo") | 所有 class="intro" 且 class="demo" 的元素 |
:first | $("p:first") | 第一个 <p> 元素 |
:last | $("p:last") | 最后一个 <p> 元素 |
:even | $("tr:even") | 所有偶数 <tr> 元素 |
:odd | $("tr:odd") | 所有奇数 <tr> 元素 |
:eq(index) | $("ul li:eq(3)") | 列表中的第四个元素(index 从 0 开始) |
:gt(no) | $("ul li:gt(3)") | 列出 index 大于 3 的元素 |
:lt(no) | $("ul li:lt(3)") | 列出 index 小于 3 的元素 |
:not(selector) | $("input:not(:empty)") | 所有不为空的 input 元素 |
:header | $(":header") | 所有标题元素 <h1> - <h6> |
:animated | 所有动画元素 | |
:contains(text) | $(":contains('W3School')") | 包含指定字符串的所有元素 |
:empty | $(":empty") | 无子(元素)节点的所有元素 |
:hidden | $("p:hidden") | 所有隐藏的 <p> 元素 |
:visible | $("table:visible") | 所有可见的表格 |
s1,s2,s3 | $("th,td,.intro") | 所有带有匹配选择的元素 |
[attribute] | $("[href]") | 所有带有 href 属性的元素 |
[attribute=value] | $("[href='#']") | 所有 href 属性的值等于 "#" 的元素 |
[attribute!=value] | $("[href!='#']") | 所有 href 属性的值不等于 "#" 的元素 |
[attribute$=value] | $("[href$='.jpg']") | 所有 href 属性的值包含以 ".jpg" 结尾的元素 |
:input | $(":input") | 所有 <input> 元素 |
:text | $(":text") | 所有 type="text" 的 <input> 元素 |
:password | $(":password") | 所有 type="password" 的 <input> 元素 |
:radio | $(":radio") | 所有 type="radio" 的 <input> 元素 |
:checkbox | $(":checkbox") | 所有 type="checkbox" 的 <input> 元素 |
:submit | $(":submit") | 所有 type="submit" 的 <input> 元素 |
:reset | $(":reset") | 所有 type="reset" 的 <input> 元素 |
:button | $(":button") | 所有 type="button" 的 <input> 元素 |
:image | $(":image") | 所有 type="image" 的 <input> 元素 |
:file | $(":file") | 所有 type="file" 的 <input> 元素 |
:enabled | $(":enabled") | 所有激活的 input 元素 |
:disabled | $(":disabled") | 所有禁用的 input 元素 |
:selected | $(":selected") | 所有被选取的 input 元素 |
:checked | $(":checked") | 所有被选中的 input 元素 |
下载信息 [文件大小: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; }