码迷,mamicode.com
首页 > Web开发 > 详细

jquery_2

时间:2016-05-29 19:42:20      阅读:150      评论:0      收藏:0      [点我收藏+]

标签:

1.bind()
bingding event handlers
like:$("div").bind("click",function(){alert("the div is clicked!");});

2.unbind()
unbinding the event handler;
like:$("div").unbind("click");

3.event.type,target,pageX,pageY
show the event attributes;
like:$("div").bind("click",function(event){
alert("Event type:" + event.types);
alert("Event pageX:" + event.pageX);
alert("Event pageY:" + event.pageY);
alert("Event taget innerHTML:" + event.target.innerHTML);
});

4.click(),blur();
also,we can bind the click or blur method directly use the two above functions;
like:$("div").click(function(){alert("I was clicked!");});

5.load(URL[,data][,callback_function])
we use this fucntion load to achieve the AJAX:load a file to a selector;
like:$("div").load("/jquery/result.html");

6.getJSON(URL[,data][,callback_funciton]);
we use this function to get JSON file and we can parse it to a JSON object;
like:$("div").click(function(){
$.getJSON("/jquery/result.json",function(jd){
$("div").html("<p>Name:" + jd.name + "</p>");
$("div").html("<p>Age:" + jd.age + "</p>");
$("div").html("<p>Sex:" + jd.sex + "</p>");
});
});

7.ajaxComplete(callback_function),ajaxStart(callback_function)
we use those function work finish or before the ajax works;

8.show(speed,callback),hide(speed,callback)
use this to show the selector;
like:$("#mydiv").show("slow",function(){alert(show finished!);});

9.toggle(speed,callback)
the function toggle achieves both show and hide;

10.fadeIn(speed,callback);fadeOut(speed,callback);
works just like the show and hide but with an effect of fade;

jquery_2

标签:

原文地址:http://www.cnblogs.com/zengneng/p/5539990.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!