`
hui253753547
  • 浏览: 46176 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
社区版块
存档分类
最新评论

jQuery笔记

 
阅读更多

一、找到你了
$("")=document.getElementById(""); $("#myDiv")

XPath
$("div p")
$("div .container")
$("div #msg")
$("table a",context) 得到context为上下文的table里面所有的连接元素。
二、JQUERY对象
jquery提供了很多便利的函数,如each(fn),但是使用这些函数的前提是:你使用的对象是Jquer对象。
1.var a = $("#cid");  
2.var b = $("<p>hello</p>");
3.var c = document.createElement("table"); var tb = $(c); 
三、代替body标签的onload
#(document).ready(Fn);
四、事件机制
$(document).ready(
 function(){
  $("#clear").click(function(){
   alert("test");
   $("form[0]").submit(validate);
  });
});
function validate(){}

五、同一函数实现set&get
$("#msg").html();  
$("#msg").html("hello");
六、ajax
$.get("search.do",{id:3},function(){//回调函数});
$.post("search.do",{id:4},function(){//回调函数});
$("#msg").ajaxStart(function(){});
$("#msg").ajaxSuccess(function(){});
七、渐入淡出
1.$("#msg").fadeIn("fast");  
2.$("#msg").fadeOut("slow"); 
上面两行代码已经分别实现了一个id为Msg的jquery对象的渐入和淡出。做一个像Gmail一样的动态加载通知条,用jquery就那么简单。两个函数接受的参数除了快慢等,还可以接收整型,作为渐入或淡出的完成时间,单位为MS。
八、plugin
这也是一个插件的时代。
jquery插件给我的感觉清一色的清洁,简单。如Jtip,要使用它的功能,只需要在你的元素的class上加上Jtip,并引入jtip.js及其样式即可以了。

加一些Jquery的资源:
http://www.visualjquery.com/index.xml 很好的API查询站点
http://jquery.com/demo/thickbox/ 知道lightBox吧,看看Jquery是怎样实现相同的东西
http://www.codylindley.com/blogstuff/js/jtip/ Jtip,实用的提示工具
http://jquery.com/plugins/ 很多牛的插件。
http://15daysofjquery.com/  jquery 的15天教程

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics