jQuery 常用代码集锦】的更多相关文章

1. 如何修改jquery默认编码(例如默认GB2312改成 UTF-8 ) 1 2 3 4 5 $.ajaxSetup({     ajaxSettings : {         contentType : "application/x-www-form-urlencoded;chartset=UTF-8"     } }); 2. jquery判断元素上是否绑定了事件 1 2 3 4 5 //jQuery event封装支持判断元素上是否绑定了事件,此方法只适用于jQuery绑定…
1. 选择或者不选页面上全部复选框 var tog = false; // or true if they are checked on load $('a').click(function() { $("input[type=checkbox]").attr("checked",!tog); tog = !tog; }); 2. 取得鼠标的X和Y坐标 $(document).mousemove(function(e){ $(document).ready(func…
1. 禁止右键点击 ? 1 2 3 4 5 $(document).ready(function(){     $(document).bind("contextmenu",function(e){             return false;     }); }); 2. 隐藏搜索文本框文字 ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 Hide when clicked in the search field, the value.(exampl…
转自:未找到 以下是jquery中比较常用的一些操作实现方式: $("标签名") //取html元素 document.getElementsByTagName("")  $("#ID") //取单个控件document.getElementById("")  $("div #ID") //取某个控件中 控件  $("#ID #ID") // 通过控件ID取其中的控件  $("…
检测IE浏览器 在进行CSS设计时,IE浏览器对开发者及设计师而言无疑是个麻烦.尽管IE6的黑暗时代已经过去,IE浏览器家族的人气亦在不断下滑,但我们仍然有必要对其进行检测.当然,以下片段亦可用于检测其它浏览器. $(document).ready(function() { if (navigator.userAgent.match(/msie/i) ){ alert('I am an old fashioned Internet Explorer'); } }); 平滑滚动至页面顶部 以下是j…
一.普通代码 1.坐标转换 ol.proj.transform(coordinate, source, destination) ol.proj.transform(coordinate, 'EPSG:4326', 'EPSG:3857') 2.根据坐标创建点要素图层 function videoPoint(getVideoPointURL) { setTimeout(function () { var vectorLayer = getLayerByTitle('视频监测点'); var ve…
获取<input />的value $("#id").val( ); 标签间的html $("#id").html('<tr><td>aaa</td> </tr>'); 隐藏/显示 $("#id").show(); $("#id").hide(); 去字符串的前后空格 $.trim(str); ID=con标签内的html的追加 $("#con")…
1.获取某天后几天的日期 //d为传入的日期 days为d后面的几天function getAfterDate(d,days){ var dd = new Date(d); dd.setDate(dd.getDate()+days); var y = dd.getFullYear(); var m = dd.getMonth()+1; var d = dd.getDate(); return y+"-"+m+"-"+d;}alert(getAfterDate('20…
页面重定位: window.location.replace("http://www.bczs.net"); window.location.href = "http://www.bczs.net"; $(location).attr('href', 'http://www.bczs.net'); $(window).attr('location', 'http://www.bczs.net'); 页面强制刷新当前页: window.location.reload(…
1.获取屏幕尺寸 document.documentElement.scrollWidth; document.documentElement.scrollHeight; $(window).width(); $(window).height(); 2.页面加载完成执行代码块及DOM加载完毕之后执行 $(document).ready(function(){ //脚本 }); $().ready(function() { //脚本 }) $(function() { //脚本 }) 3.页面分辨…