调整匹配元素的透明度。
fx.fadeTo(elm, duration,opacity, callback)
Example: 点击第一个段落使其透明度渐变成 0.33 (33%,大约三分之一透明度)。
<!DOCTYPE html> <html> <head> <style> p { font-size:150%; cursor:pointer; } </style> <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.3/require.min.js"></script> <script> require.config({ baseUrl: "./", packages: [{ name: "skylark", location: "../../../src/skylark" }, ] }); </script> </head> <body> <p> Click this paragraph to see it fade. </p> <p> Compare to this one that won't fade. </p> <script> require(["skylark/query", "skylark/finder", "skylark/fx"], function(query,finder,fx) { query("p:first").on("click", function() { fx.fadeTo(finder.find("p:first"),"slow",0.33); }); }); </script> </body> </html>