jQuery UI 实例 - 显示(Show)

ゝ一纸荒年。 2024-03-23 10:45 135阅读 0赞

如需要了解更多有关.show()方法的细节,请查看API文档.show()。

.show() 显示

点击按钮预览特效。

  1. <span style="color:#333333"><!doctype html>
  2. <html lang="zh-cn">
  3. <头>
  4. <元字符集="utf-8">
  5. <title>jQuery UI 特效 - .show() 表演</title>
  6. <link rel="stylesheet" href="//code.jquery.com/ui/1.10.4/themes/smoothness/jquery-ui.css">
  7. <script src="//code.jquery.com/jquery-1.9.1.js"></script>
  8. <script src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
  9. <link rel="stylesheet" href="http://jqueryui.com/resources/demos/style.css">
  10. <样式>
  11. .toggler { 宽度:500px;高度:200px;}
  12. #button { 填充:.5em 1em; 文字修饰:无;}
  13. #effect { 宽度:240px;高度:135px;填充:0.4em;位置:相对;}
  14. #effect h3 { 保证金:0;填充:0.4em;文本对齐:居中;}
  15. </样式>
  16. <脚本>
  17. $(函数() {
  18. // 运行当前选择中的特性
  19. 函数运行效果(){
  20. // 从中获得特殊类型
  21. var selectedEffect = $( "#effectTypes" ).val();
  22. // 大多数的特效类默认不需要传递选项
  23. var options = {};
  24. // 一些特效带有必需的参数
  25. if ( selectedEffect === "scale" ) {
  26. options = { percent: 100 };
  27. } else if ( selectedEffect === "size" ) {
  28. options = { to: { width: 280, height: 185 } };
  29. }
  30. // 运行特效
  31. $( "#effect" ).show( selectedEffect, options, 500, callback );
  32. };
  33. // 回调函数
  34. function callback() {
  35. setTimeout(function() {
  36. $( "#effect:visible" ).removeAttr( "style" ).fadeOut();
  37. }, 1000 );
  38. };
  39. // 根据选择菜单值设置特效
  40. $( "#button" ).click(function() {
  41. runEffect();
  42. return false;
  43. });
  44. $( "#effect" ).hide();
  45. });
  46. </script>
  47. </head>
  48. <body>
  49. <div class="toggler">
  50. <div id="effect" class="ui-widget-content ui-corner-all">
  51. <h3 class="ui-widget-header ui-corner-all">显示(显示)</h3>
  52. <p>
  53. Etiam libero neque, luctus a, eleifend nec, semper at, lorem。种子脚。Nulla lorem metus,adipiscing ut,luctus sed,hendrerit vitae,mi。
  54. </p>
  55. </div>
  56. </div>
  57. <select name="effects" id="effectTypes">
  58. <option value="blind">百叶窗特效(盲效果)</option>
  59. <option value="bounce">反弹特效(Bounce Effect)</option>
  60. <option value="clip">剪辑特效(剪辑效果)</option>
  61. <option value="drop">降落特效(Drop Effect)</option>
  62. <option value="explode">爆炸特效(爆炸效果)</option>
  63. <option value="fold">折叠特效(折叠效果)</option>
  64. <option value="highlight">突出特效(Highlight Effect)</option>
  65. <option value="puff">膨胀特效(Puff Effect)</option>
  66. <option value="pulsate">跳动特效(Pulsate Effect)</option>
  67. <option value="scale">缩放特效(Scale Effect)</option>
  68. <option value="shake">震动特效(Shake Effect)</option>
  69. <option value="size">尺寸特效(Size Effect)</option>
  70. <option value="slide">滑动特效(Slide Effect)</option>
  71. </select>
  72. <a href="#" id="button" class="ui-state-default ui-corner-all">运行特效</a>
  73. </body>
  74. </html></span>

发表评论

表情:
评论列表 (有 0 条评论,135人围观)

还没有评论,来说两句吧...

相关阅读