最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

.fadeTo()

.fadeTo( duration, opacity, [ callback ] ) 返回: jQuery

描述: 調(diào)整匹配元素的透明度。

  • version added: 1.0.fadeTo( duration, opacity, [ callback ] )

    duration一個字符串或者數(shù)字決定動畫將運行多久。

    opacity一個0至1之間表示目標透明度的數(shù)字。

    callback在動畫完成時執(zhí)行的函數(shù)。

  • version added: 1.4.3.fadeTo( [ duration ], opacity, [ easing ], [ callback ] )

    duration一個字符串或者數(shù)字決定動畫將運行多久。

    opacity一個0至1之間表示目標透明度的數(shù)字。

    easing一個用來表示使用哪個緩沖函數(shù)來過渡的字符串

    callback在動畫完成時執(zhí)行的函數(shù)。

.fadeTo() 方法通過匹配元素的不透明度做動畫效果。

延時時間是以毫秒為單位的,數(shù)值越大,動畫越慢,不是越快。字符串 'fast''slow' 分別代表200和600毫秒的延時。如果提供任何其他字符串,或者這個duration參數(shù)被省略,那么默認使用400毫秒的延時。和其他效果方法不同,.fadeTo()需要明確的指定duration參數(shù)。

如果提供回調(diào)函數(shù)參數(shù),回調(diào)函數(shù)會在動畫完成的時候調(diào)用。這個對于將不同的動畫串聯(lián)在一起按順序排列是非常有用的。這個回調(diào)函數(shù)不設(shè)置任何參數(shù),但是this是存在動畫的DOM元素,如果多個元素一起做動畫效果,值得注意的是這個回調(diào)函數(shù)在每個匹配元素上執(zhí)行一次,不是這個動畫作為一個整體。

我們可以給任何元素做動畫,比如一個簡單的圖片:

<div id="clickme">
    Click here
  </div>
  <img id="book" src="book.png" alt="" width="100" height="123" />
  With the element initially shown, we can dim it slowly:
  $('#clickme').click(function() {
    $('#book').fadeTo('slow', 0.5, function() {
      // Animation complete.
    });
  });
  

duration設(shè)置為0,這個方法只是改變opacity CSS屬性,所以.fadeTo(0, opacity).css('opacity', opacity)是一樣的效果。

注意:

  • 所有的jQuery效果,包括 .fadeTo(),能使用jQuery.fx.off = true關(guān)閉全局性。更多信息請查看jQuery.fx.off。

例子:

舉例: 將第一個段落的不透明度設(shè)置成0.33(33%),在600毫秒內(nèi)完成這些動畫。

<!DOCTYPE html>
<html>
<head>
  <script src="http://code.jquery.com/jquery-latest.min.js"></script>
</head>
<body>
  <p>
Click this paragraph to see it fade.
</p>

<p>
Compare to this one that won't fade.
</p>
<script>
$("p:first").click(function () {
$(this).fadeTo("slow", 0.33);
});
</script>

</body>
</html>

Demo:

Example: 點擊將div設(shè)置成隨機的不透明度,在200毫秒內(nèi)完成這些動畫。

<!DOCTYPE html>
<html>
<head>
  <style>
p { width:80px; margin:0; padding:5px; }
div { width:40px; height:40px; position:absolute; }
div#one { top:0; left:0; background:#f00; }
div#two { top:20px; left:20px; background:#0f0; }
div#three { top:40px; left:40px; background:#00f; }
</style>
  <script src="http://code.jquery.com/jquery-latest.min.js"></script>
</head>
<body>
  <p>And this is the library that John built...</p>

<div id="one"></div>
<div id="two"></div>
<div id="three"></div>
<script>
$("div").click(function () {
$(this).fadeTo("fast", Math.random());
});
</script>

</body>
</html>

Demo:

Example: Find the right answer! The fade will take 250 milliseconds and change various styles when it completes.

<!DOCTYPE html>
<html>
<head>
  <style>
div, p { width:80px; height:40px; top:0; margin:0; 
position:absolute; padding-top:8px; }
p { background:#fcc; text-align:center; }
div { background:blue; }
</style>
  <script src="http://code.jquery.com/jquery-latest.min.js"></script>
</head>
<body>
  <p>Wrong</p>
<div></div>
<p>Wrong</p>
<div></div>

<p>Right!</p>
<div></div>
<script>
var getPos = function (n) {
return (Math.floor(n) * 90) + "px";
};
$("p").each(function (n) {
var r = Math.floor(Math.random() * 3);
var tmp = $(this).text();
$(this).text($("p:eq(" + r + ")").text());
$("p:eq(" + r + ")").text(tmp);
$(this).css("left", getPos(n));
});
$("div").each(function (n) {
      $(this).css("left", getPos(n));
    })
.css("cursor", "pointer")
.click(function () {
      $(this).fadeTo(250, 0.25, function () {
            $(this).css("cursor", "")
                   .prev().css({"font-weight": "bolder",
                                "font-style": "italic"});
          });
    });

</script>

</body>
</html>

Demo:

jQuery 1.6 API 中文版腳本之家整理、修訂 (2011年6月)
盐山县| 双峰县| 富平县| 邵阳市| 双流县| 通山县| 凤城市| 吐鲁番市| 祁阳县| 正镶白旗| 名山县| 金平| 体育| 宣化县| 盖州市| 天津市| 大港区| 太保市| 平定县| 合作市| 高雄市| 青川县| 岑溪市| 和田县| 罗平县| 阿拉善右旗| 虎林市| 无为县| 河北区| 四会市| 湖南省| 姚安县| 通辽市| 青田县| 亚东县| 临江市| 遂川县| 武定县| 观塘区| 南京市| 安徽省|