多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
# jQuery UI API - 转移特效(Transfer Effect) ## 所属类别 [特效(Effects)](ref-effects.html) ## 用法 **描述:**把一个元素的轮廓转移到另一个元素。 ``` transfer ``` | 参数 | 类型 | 描述 | | --- | --- | --- | | className | String | 转移的元素将接收的参数化的 class 名称。 | | to | String | jQuery 选择器,要转移到的元素。 | 当尝试两个元素之间的可视化交互时非常有用。 转移的元素本身带有 class `ui-effects-transfer`,其他的样式需要由您来定义,比如添加背景或边框。 ## 实例 在绿色元素上点击把它转移到另一个元素。 ``` <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>转移特效(Transfer Effect)演示</title> <link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css"> <style> div.green { width: 100px; height: 80px; background: green; border: 1px solid black; position: relative; } div.red { margin-top: 10px; width: 50px; height: 30px; background: red; border: 1px solid black; position: relative; } .ui-effects-transfer { border: 1px dotted black; } </style> <script src="//code.jquery.com/jquery-1.10.2.js"></script> <script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script> </head> <body> <div class="green"></div> <div class="red"></div> <script> $( "div" ).click(function() { var i = 1 - $( "div" ).index( this ); $( this ).effect( "transfer", { to: $( "div" ).eq( i ) }, 1000 ); }); </script> </body> </html> ```