- 博客(16)
- 收藏
- 关注
原创 js 面向对象开发组件参考3
--jq 类级别插件的开发--静态方法jQuery.myAlert=function(){ }---extend()方法jQuery.extend({ myAlert:function(){ }}) 3.使用名空间jQuery.my={ myAlert:function(obj){//传入的是jq dom对象 return o
2017-05-07 13:28:18 231
原创 js 面向对象组件开发参考2
;(function($){ var Box=function(i){ var that=this; this.btn=$(i); this.btn.click(function(){ that.a(); }) }; Box.prototype.a=function(){
2017-05-07 11:25:00 229
原创 js 鼠标滚动
var oTxt=document.getElementById("txt");var scrollFunc=function(e){ var direct=0; e=e || window.event; var t1=document.getElementById("wheelDelta"); var t2=document.getElementById("d
2017-05-07 11:19:32 335
原创 js面向对象组件开发参考1
;(function($){ var My=function(poster){ this.poster=poster; this.posterItemMain=poster.find("ul.post_list"); this.pre=poster.find(".pre"); this.nxt=poster.find(".ne
2017-05-07 11:16:14 382
原创 js 事件委托
ul.onclick=function(ev){ var e= ev || window.event; var target = e.srcElement || e.target; e.cancelBubble = true; e.stopPropagation(); if(target){ if(target.className){
2017-05-07 10:45:28 177
原创 js 获取变量的类型
var arr=["a","b","c"];var cc=Object.prototype.toString.call(arr).slice(8,-1);console.log(cc);//Array
2017-05-07 10:34:04 1000
原创 js 模块模式
var module=(function(){ var name="张三", age=10; function alt(){ alert(age); }; var my={ num:function(){ return alt(); }, getName:
2017-05-06 23:56:59 231
原创 js 原型莲
/**数组对象原型链* arr.__proto__===Array.prototype*Array.prototype.constructor===Array*Array.__proto__===Function.prototype*Function.prototype.__proto__===Object.prototype*Object.prototype.__proto__===
2017-05-06 23:53:13 203
原创 js 获取数组中最大值
var arr=[1,2,3,1];var max=Math.max.apply(null,arr); //合并数组方式1Array1.concat(Array2);//合并数组方式2(不推荐)Array.prototype.push.apply(Array1,Array2);理由:实验 Array1和Array2分别是10万条数据方式1:方式2 = 4 : 69
2017-05-06 23:22:22 676
原创 js 禁止鼠标滚动
window.onload=function(){ var oDiv=document.getElementById("top"); oDiv.onmouseover = function () { if(window.event){ document.onmousewheel = function () {
2017-05-06 23:15:22 1608
原创 js select下拉框的值
window.onload=function(){ var oBtn=document.getElementById("btn"); var sel=document.getElementById("select"); oBtn.onclick=function(){ var index=sel.selectedIndex ; var val
2017-05-06 23:06:39 194
原创 js html代码转译防xss攻击
function safeHtml(a){//转译html代码 var s=""; for(var i=0;ia.length;i++){ var arg=String(a); s=arg.replace(/&/g,"&").replace(/,"<").replace(/>/g,">"); console.log
2017-05-06 23:04:37 1887 1
原创 js设置cookie
function setCookie(c_name,value,expiredays)//设置cookie{ var exdate=new Date();//注意加密 var aa=exdate.getTime()+expiredays*3600*24*1000; document.cookie=c_name+ "=" + value+ ((exp
2017-05-06 22:53:07 191
原创 js ajax
ajax({ url: "./TestXHR.aspx", //请求地址 type: "POST", //请求方式 data: { name: "super", age: 20 }, //请求参数 dataType: "json", success: function (re
2017-05-06 22:35:29 176
原创 js浏览器类别检测及操作系统
function isHostMethod(object,property){ var t=typeof object[property]; return t=="function" || (!!(t=="object" && object[property])) || t=="unknown";//!!表示返回的是一个布尔值}浏览器类别检测及操作系统var module=(fu
2017-05-06 22:28:43 268
原创 js浏览器能力检测
var client = (function(){ //rendering engines var engine = { ie: 0, gecko: 0, webkit: 0, khtml: 0, opera: 0, //complete version
2017-05-06 22:02:29 972
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人