jQuery整理2

來源:互聯網
上載者:User

標籤:

七、jQuery效果

  (1)jQuery隱藏和顯示 

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

  (2)jQuery淡入淡出fade

//淡入$("#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.用法如上。

  (4)jQuery回調

$("button").click(function(){    $("p").hide(1000,function(){    alert("結束,這個方法被稱為回調");    $("p").css("color","red").slideUp(1000).slideDown(1000);});});

 

八、jQuery中css設定和盒子模型。尋找API中css中可以設定的屬性,記住格式即可。熟悉addClass方法。

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

 

九、jQuery遍曆和過濾

  (1)jQuery遍曆分為向上遍曆、向下遍曆、同級遍曆

    向下遍曆:children(),find().children只能選擇兒子輩,參數可選,而find可以尋找所有的下級,參數必 要。

    向上遍曆: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是排除標準。

 

十、jQuery擴充

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

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

  3.$.noConflict();

 

jQuery整理2

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.