
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有帐号?立即注册
x
1.jQuery UI
1. 分类
1. Effects 效果
* 扩展jQuery中的animate()方法,可以使用扩展一下样式属性
* backgroundColor
* borderBottomColor
* borderLeftColor
* borderRightColor
* borderTopColor
* Color
* outlineColor
* effect()方法 - 提供各种各样的效果
例如:
- <!doctype html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>jQueryUI扩展animate方法</title>
- <!-- 1. 引入jQuery文件 -->
- <script src="jquery-1.11.3.js"></script>
- <!-- 2. 引入jQuery UI的JS文件 -->
- <script src="jquery-ui.js"></script>
- <!-- 3. 引入jQuery UI的CSS文件 -->
- <link rel="stylesheet" href="jquery-ui.css">
- <style>
- div {
- width : 200px;
- height : 200px;
- background-color : pink;
- position:absolute;
- }
- </style>
- </head>
- <body>
- <div></div>
- <script>
- $("div").animate({
- backgroundColor : "green",
- left:300
- },3000).animate({
- backgroundColor : "blue",
- top:300,
- },3000).animate({
- backgroundColor : "red",
- left:500,
- },3000).animate({
- backgroundColor : "yellow",
- width:150,
- height:150,
- },3000);
- </script>
- </body>
- </html>
复制代码效果:
2. 组件
* Dialog - 对话框
例如:
- <!doctype html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>动态打开对话框</title>
- <script src="jquery-1.11.3.js"></script>
- <script src="jquery-ui.js"></script>
- <link rel="stylesheet" href="jquery-ui.css">
- </head>
- <body>
- <button>打开对话框</button>
- <div id="dialog" title="对话框">
- <p>这是一个具有样式的对话框.</p>
- </div>
- <script>
- $("button").button().click(function(){
- $("#dialog").dialog("open");
- });
- /*
- dialog(options)函数
- * 作用 - 实现一个对话框的样式
- * 选项
- * autoOpen - 是否自动打开,Boolean值
- * show - 表示设置显示对话框的动画效果
- * hide - 表示设置隐藏对话框的动画效果
- * modal - 表示是否为模式对话框,Boolean
- * width和height - 设置对话框的宽高
- * buttons - 表示设置button
- */
- $("#dialog").dialog({
- autoOpen : false,
- modal : true,
- //width : 800,
- //height : 500,
- show : {
- effect : "fade",
- duration : 500
- },
- hide : {
- effect : "blind",
- duration : 500
- },
- buttons : [
- {
- text : "确认",
- click : function(){
- $("#dialog").dialog("close");
- }
- },
- {
- text : "取消",
- click : function(){
- $("#dialog").dialog("close");
- }
- }
- ]
- });
- </script>
- </body>
- </html>
复制代码效果:
点击 打开对话框:
点击 确认 后,对话框消失。
* 交互
* 拖拽
* Draggable - 拖动
* Droppable - 投放
* 排序(Sortable)
* 缩放(Resizable)
* 选择(Selectable)
例如:
- <!doctype html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>Droppable</title>
- <script src="jquery-1.11.3.js"></script>
- <script src="jquery-ui.js"></script>
- <link rel="stylesheet" href="jquery-ui.css">
- <style>
- #draggable { width: 100px; height: 100px; padding: 0.5em; float: left; margin: 10px 10px 10px 0; }
- #droppable { width: 150px; height: 150px; padding: 0.5em; float: left; margin: 10px; }
- </style>
- </head>
- <body>
- <div id="draggable" class="ui-widget-content">
- <p>Drag me to my target</p>
- </div>
-
- <div id="droppable" class="ui-widget-header">
- <p>Drop here</p>
- </div>
- <script>
- // 被拖动的元素 - 称之为源元素
- $("#draggable").draggable();
- // 拖拽到的元素 - 称之为目标元素
- $("#droppable").droppable({
- // 指定源元素
- accept: "#draggable",
- // 活动时的样式
- activeClass: "ui-state-highlight",
- // 投放事件
- drop : function(event,ui){
- $( this )
- .addClass( "ui-state-highlight" )
- .find( "p" )
- .html( "Dropped!" );
- }
- });
- </script>
- </body>
- </html>
复制代码效果:
拖动后:
|
|
|
|
|
|