`
caniggia1986
  • 浏览: 149655 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论
文章列表
javascript:mctmp(0); in ie6: document.getElementsByName(nameValue) will return the element which id attribute equals to nameValue document.getElementById(idValue) will return the element which name attribute equals to idValue so prevent to use the same id and name attribute value in dom! va ...
//属性选择符 //author:司徒正美 ref:http://www.cnblogs.com/rubylouvre/archive/2009/10/26/1590102.html //正则支持 tag[attrName ^\$\*\~\!=attrValue] var getElementsByAttribute = function(search) { var tag = /([\*a-zA-Z1-6]*)?(\[(\w+)\s*(\^|\$|\*|\||~|!)?=?\s*([\w\u00C0-\uFFFF\s\-_\.]+)?\])?/, ...

Node.contains

/* code ref http://www.cnblogs.com/rubylouvre/archive/2009/10/14/1583523.html IE有contains方法。如果A元素包含B元素,则返回true,否则false。唯一不支持这个方法的是firefox。 不过火狐支持compareDocumentPosition() 方法,这是W3C制定的方法,标准浏览器都支持。 它的使用形式与contains差不多,但返回的不是一个布尔值,而是一个很奇怪的数值,它是通过如下方式累加计算出来的: 二进制 数值 含义 000000 0 元素一致 0 ...
//code ref http://www.cnblogs.com/rubylouvre/archive/2009/07/24/1529640.html //支持 多class搜索 ie:getElementsByClassName("classA classB") var getElementsByClassName = function (searchClass, node, tag) { var node = node || document; var tag = tag || "*"; if (docum ...
<a href="http://bbs.51js.com/forum.php?mod=viewthread&tid=74167&extra=pageD1%3D&page=1">ref</a> <pre> 1.基本类型string boolean undefined null number皆可直接用=赋值 2.普通object clone //最简单clone function objectClone(){ var ret=new Object(); for(var p in this){ ret[ ...
如果想重写jQuery某个方法又不想直接改源码,你可以这样 改写unique() (function($){ var _old = $.unique;//备份原始方法 $.unique = function(arr){ //如果是dom对象就使用原始方法 if (!!arr[0].nodeType){ return _old.apply(this,arguments); } else { //使用grep/inArray组合方法去重 ...
1.选择:优先用#id,使用.class前面带上tag名称,多次操作是使用变量保存(或链式操作)。 2.sizzle:1.3后采用的选择器引擎采用‘自右向左’取代传统的‘自左向右’,右边选择器更加明确,比如 $('div.class span.class2'),因此在写选择器时需要考虑这点 3.绑定事件时用live()/delegate()取代bind() 4.操作dom时可以先取出dom-&gt;操作dom—&gt;恢复到原来的位置 var theForm = $('#myForm'); var formParent = theForm.parent(); theF ...
<p>一个非常好的入门教程<a title="30分钟入门" href="http://deerchao.net/tutorials/regex/regex.htm" target="_blank">link</a></p> <p><a href="https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/RegExp" target="_blank"& ...
http://www.cnblogs.com/nuysoft/archive/2011/11/14/2248023.html http://www.cnblogs.com/fjzhou/
this:在Javascript中,This关键字永远都指向函数(方法)的所有者. http://www.laruence.com/2009/09/08/1076.html 原型链和原型:The prototype is only used for properties inherited by objects/instances created by that function. The function itself does not use the associated prototype http://www.laruence.com/2010/05/13/1462.html 作用域: ...
//和eval()不同的是他用全局上下文(window)用于加载运行在全局范围的外部脚本 globalEval: function( data ) { if ( data && rnotwhite.test( data ) ) { //IE用execScript //标准用匿名函数使全局window作为上下文调用eval ( window.execScript || function( data ) { window[ "eval" ].call( window, data );//chrome一些版本 ...
parseXML: function(data, xml, tmp) { if (window.DOMParser) { //标准 IE9可以 tmp = new DOMParser(); xml = tmp.parseFromString(data, "text/xml"); } else { // IE xml = new ActiveXObject("Microsoft.XMLDOM"); xml.async = "false" ...
// A crude way of determining if an object is a window isWindow: function( obj ) { return obj && typeof obj === "object" && "setInterval" in obj; } Here is how it works: 1. it detects if there is an object being returned 2. it detects if the object type i ...
var first = 'hi there'; var first = (function() { console.log("first", first); // undefined var first = "hello world"; })(); //相当于 var first = 'hi there'; var first = (function() { var first;//the variable declaration moved to the top console.log(&quo ...
http://www.codebit.cn/javascript/javascript-replace.html String.prototype.format = function() { var args = arguments; return this.replace(/\{(\d+)\}/g, function(m,i){ return m+args[i]; }); }; console.log("{0} is {1}".format(&q ...
Global site tag (gtag.js) - Google Analytics