jQuery--效果和遍历

7、jQuery效果javascript

  (1)jQuery隐藏和显示 css

//隐藏
$("#hide").click(function(){
    $("p").hide(1000);
});
//显示
$("#show").click(function(){
    $("p").show(1000);
});
//隐藏/显示
$("#toggle").click(function(){
    $("p").toggle(1000);
});

  (2)jQuery淡入淡出fadejava

//淡入
$("#in").on("click",function(){
    $("#div1").fadeIn(1000);
    $("#div2").fadeIn(1000);
    $("#div3").fadeIn(1000);
});
//淡出
$("#out").on("click",function(){
    $("#div1").fadeOut(1000);
    $("#div2").fadeOut(1000);
    $("#div3").fadeOut(1000);
});
//淡入/淡出
$("#toggle").on("click",function(){
    $("#div1").fadeToggle(1000);
    $("#div2").fadeToggle(1000);
    $("#div3").fadeToggle(1000);
});
//淡化
$("#to").on("click",function(){
    $("#div1").fadeTo(1000,0.3);
    $("#div2").fadeTo(1000,0.5);
    $("#div3").fadeTo(1000,0.7);
});

  (3)jQuery效果 滑动 slideDown,slideUp,slideToggle.用法如上。ide

  (4)jQuery回调this

$("button").click(function(){
    $("p").hide(1000,function(){
    alert("结束,这个方法被称为回调");

    $("p").css("color","red").slideUp(1000).slideDown(1000);
});
});

 

8、jQuery中css设置和盒子模型。查找API中css中能够设置的属性,记住格式便可。熟悉addClass方法。blog

  在盒子模型中,要理解height,innerHeight,outerHeight,width,innerWidth,outerWidth所包含的范围,outerHeight=innerHeight+(margin/0)+border =(Height+padding)+(margin/0)+border.ip

 

9、jQuery遍历和过滤io

  (1)jQuery遍历分为向上遍历、向下遍历、同级遍历ast

    向下遍历:children(),find().children只能选择儿子辈,参数可选,而find能够查找全部的下级,参数必 要。function

    向上遍历:parent(),parents(),parentUntil().其中parent只招上一级的元素,parents是全部上级。即直属上司和全部上司的区别。而parentUntil的区别在于能够定义上司的范围。

    同级遍历:sibings(),next(),nextAll(),nextUntil(),prev(),preAll(),preUntil().其中sibings是修改掉除他以外的全部同级元素,next是他的同桌,nextAll是同桌和同桌的同桌,nextUntil向下的区间范围。后面的几个方法是方向相反而已。

  (2)jQuery过滤 first(),last(0,eq(),filter(),not().first和last,eq顾名思义。而filter方法筛选一下,not是排除标准。

 

10、jQuery扩展

  1.$.myjq=function(){alert("hello")};$.myjq();

  2.$.fn.myjq=function(){$(this).text("hello");};$("div").myjq();

  3.$.noConflict();

相关文章
相关标签/搜索