1.淡化内容:
vat time = 3000; //设置显示/隐去时间/速度
$("p").fadeOut(time); //渐渐消失
$("p").fadeIn(time); //渐渐出现
2.$("#cicle").animate(style, speed);//使动画操作
$("#cicle").animate({
width:200px;
height:200px;
}, 800);
3.用ajax加载数据:
$.get("test.html", function(data) {
alert(data);
});
//$.get()是$.ajax()的简化!
$.ajax({
url:"test.html"
}).done(function(data) {
alert(data);
});
4.正则表达式:
<script>
var regex=/great/;
var string="Regex is great!";
var result = string.match(regex);
alert(result);
</script>
5.jQuery UI:
1>draggables, droppable, resizable:
Eg:
<span style="font-size:14px;"><html> <head> <title>jQuery UI</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width; initial-scale=1.0"> <script type="text/javascript" src="jQuery.min.js"></script> <script type="text/javascript" src="jquery-ui.min.js"></script> <link rel="stylesheet" href="http://code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css"> <style> #square { width:200px; height:200px; background:yellow; } #target { width:200px; height:200px; background:red; } #resizable { width:200px; height:200px; background:blue; } </style> </head> <body> <div id="square"></div> <div id="target"></div> <div id="resizable"></div> <script type="text/javascript"> $("#square").draggable(); $("#resizable").resizable(); $("#target").droppable({ drop: function(ui, event) { $("#square").css("background", "green"); } }); </script> </body> </html></span>
<!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>jQuery UI 折叠面板(Accordion) - 默认功能</title> <link rel="stylesheet" href="http://apps.bdimg.com/libs/jqueryui/1.10.4/css/jquery-ui.min.css"> <script src="http://apps.bdimg.com/libs/jquery/1.10.2/jquery.min.js"></script> <script src="http://apps.bdimg.com/libs/jqueryui/1.10.4/jquery-ui.min.js"></script> <link rel="stylesheet" href="http://jqueryui.com/resources/demos/style.css"> <script> $(function() { $( "#accordion" ).accordion(); }); </script> </head> <body> <div id="accordion"> <h3>部分 1</h3> <div> <p> Mauris mauris ante, blandit et, ultrices a, suscipit eget, quam. Integer ut neque. Vivamus nisi metus, molestie vel, gravida in, condimentum sit amet, nunc. Nam a nibh. Donec suscipit eros. Nam mi. Proin viverra leo ut odio. Curabitur malesuada. Vestibulum a velit eu ante scelerisque vulputate. </p> </div> <h3>部分 2</h3> <div> <p> Sed non urna. Donec et ante. Phasellus eu ligula. Vestibulum sit amet purus. Vivamus hendrerit, dolor at aliquet laoreet, mauris turpis porttitor velit, faucibus interdum tellus libero ac justo. Vivamus non quam. In suscipit faucibus urna. </p> </div> <h3>部分 3</h3> <div> <p> Nam enim risus, molestie et, porta ac, aliquam ac, risus. Quisque lobortis. Phasellus pellentesque purus in massa. Aenean in pede. Phasellus ac libero ac tellus pellentesque semper. Sed ac felis. Sed commodo, magna quis lacinia ornare, quam ante aliquam nisi, eu iaculis leo purus venenatis dui. </p> <ul> <li>List item one</li> <li>List item two</li> <li>List item three</li> </ul> </div> <h3>部分 4</h3> <div> <p> Cras dictum. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Aenean lacinia mauris vel est. </p> <p> Suspendisse eu nisl. Nullam ut libero. Integer dignissim consequat lectus. Class aptent taciti sociosqu ad litora torquent per conubia nostra, per inceptos himenaeos. </p> </div> </div> </body> </html>
<html> <head> <title>jQuery</title> <meta charset="utf-8"> <meta name="viewport" content="width=device-width; initial-scale=1.0"> <link rel="stylesheet" href="http://apps.bdimg.com/libs/jqueryui/1.10.4/css/jquery-ui.min.css"> <script src="http://apps.bdimg.com/libs/jquery/1.10.2/jquery.min.js"></script> <script src="http://apps.bdimg.com/libs/jqueryui/1.10.4/jquery-ui.min.js"></script> <link rel="stylesheet" href="http://jqueryui.com/resources/demos/style.css"> <style> ul li { font-size:25px; } </style> </head> <body> <ul id="mylist"> <li>ppp</li> <li>aaa</li> <li>sss</li> </ul> <script type="text/javascript"> $("#mylist").sortable(); </script> </body> </html>
<span style="color:#FF0000;"><link rel="stylesheet" href="http://apps.bdimg.com/libs/jqueryui/1.10.4/css/jquery-ui.min.css"> <script src="http://apps.bdimg.com/libs/jquery/1.10.2/jquery.min.js"></script> <script src="http://apps.bdimg.com/libs/jqueryui/1.10.4/jquery-ui.min.js"></script> <link rel="stylesheet" href="http://jqueryui.com/resources/demos/style.css"></span>这四条引入外部的函数库及样式文件尤为重要!!!