jQuery1.2.6的改进

1 ,   .toggle() 能接受更多的函数了。
 程序代码
$("div").toggle(function(){
  $(this).removeClass("three").addClass("one");
}, function(){
  $(this).removeClass("one").addClass("two");
}, function(){
  $(this).removeClass("two").addClass("three");
});


2,index() 索引 方法。
 程序代码
var test = $("div.test");
$("div").index( test ) == 3

也就是说 div.test在  页面中所有div 中的索引 (第几个)。

3,jQuery.makeArray 是任何东西组成 集合。
 程序代码
jQuery.makeArray( document.getElementsByTagName("div") )
// => [ div, div, div ]

jQuery.makeArray( true )
// => [ true ]

jQuery.makeArray()
// => []


4,beforeSend 能取消ajax.
 程序代码
$.ajax({
  beforeSend: function(){
    return $("#input").val() == ""; //中断
  },
  url: "test.php"
});

5,slideDown速度控制.
 程序代码
jQuery.fx.speeds.slow = 1000;
$("#test").slideDown("slow");


1.2.3跟1.2.6对比:
http://spreadsheets.google.com/pub?key=pFIHldY_CksyThxfgx6krfA


另外:
另外看到1.2.6中有上一版1.2.3里没有的几个函数,官网文档还没跟上,我就自己随手写点。不放进中文文档了。 

相比1.2.6版本中,1.2.3里只提供了offset,再加上早先的height,width,到现在已经完全把这个插件加进来了。Dimensions插件已然融入jquery了: 

offsetParent 
用于检测对应元素实际的相对偏移的父对象 
返回值:jQuery 
示例: 
<div style="position:relative" id="p"> 
    <div> 
        <div id="c" style="position:absolute;left:30px">dd</div> 
    </div> 
</div> 

$("#c").offsetParent()[0].id    // p 

position 
用于检测实际的相对偏移,相对于上面那个函数所取得的对象。 
返回值{top:xxx,left:xxx} 
示例: 
$("#c").position().left   //30 

scrollTop,scrollLeft 
用于元素内部的滚动条,比如一个textarea,可以用来滚动 
JQ传统咯,即可以设置也获取值 

innerHeight, innerWidth 
用来获取元素实际内部大小 
innerHeight=height+paddingTop+paddingBottom 

outerHeight,outerWidth 
用于获取元素实际外部大小。 

如果使用outerHeight()则返回值为 
height+borderTop+borderBottom 

如果使用outerHeight(true),则返回值为 
height+borderTop+borderBottom+marginTop+marginBottom  


本篇文章来源于 cssrain.cn 原文链接:http://www.cssrain.cn/article.asp?id=844

原文地址:https://www.cnblogs.com/luluping/p/1251628.html