`
txf2004
  • 浏览: 7076868 次
  • 性别: Icon_minigender_1
  • 来自: 上海
社区版块
存档分类
最新评论

jQuery_API_07_Events

阅读更多

版权声明:原创作品,允许转载,转载时请务必以超链接形式标明文章原始出版、作者信息和本声明。否则将追究法律责任。http://blog.csdn.net/mayongzhan - 马永占,myz,mayongzhan

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Language" content="utf-8" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="author" content="马永占(MyZ)" />
<meta name="Copyright" content="马永占(MyZ)" />
<meta name="description" content="" />
<meta name="keywords"content="" />
<link rel="icon" href="" type="image/x-icon" />
<link rel="shortcut icon" href="" type="image/x-icon" />
<link href="" rel="stylesheet" type="text/css" />
<title></title>
<style type="text/css">

</style>
<script type="text/javascript" src="jquery-1.2.6.js"></script>
</head>
<body>

<script type="text/javascript">
$("document").ready(function(){
////////////////////////////////////////////////////////////////////////////////////////
//Page Load:

//ready( fn ) Returns: jQuery
//Binds a function to be executed whenever the DOM is ready to be traversed and manipulated.
//$(document).ready(function(){
// // Your code here...
//});
////////////////////////////////////////////////////////////////////////////////////////
//Event Handling:

//bind( type, data, fn ) Returns: jQuery
//Binds a handler to one or more events (like click) for each matched element. Can also bind custom events.
//$("p").bind("click", function(){
// alert( $(this).text() );
//});
//or
//function handler(event) {
// alert(event.data.foo);
//}
//$("p").bind("click", {foo: "bar"}, handler)

//one( type, data, fn ) Returns: jQuery
//Binds a handler to one or more events to be executed once for each matched element.
//$("p").one("click", function(){
// alert( $(this).text() );
//});

//trigger( type, data ) Returns: jQuery
//Trigger a type of event on every matched element.
//$("form:first").trigger("submit")

//triggerHandler( type, data ) Returns: jQuery
//This particular method triggers all bound event handlers on an element (for a specific event type) WITHOUT executing the browser's default actions.
// $("#old").click(function(){
// $("input").trigger("focus");
// });
// $("#new").click(function(){
// $("input").triggerHandler("focus");
// });
// $("input").focus(function(){
// $("<span>Focused!</span>").appendTo("body").fadeOut(1000);
// });

//unbind( type, fn ) Returns: jQuery
//This does the opposite of bind, it removes bound events from each of the matched elements.
//$("p").unbind()
//or
//$("p").unbind( "click" )
////////////////////////////////////////////////////////////////////////////////////////
//Interaction Helpers:

//hover( over, out ) Returns: jQuery
//Simulates hovering (moving the mouse on, and off, an object). This is a custom method which provides an 'in' to a frequent task.
// $("li").hover(
// function () {
// $(this).append($("<span> ***</span>"));
// },
// function () {
// $(this).find("span:last").remove();
// }
// );

//toggle( fn, fn2, fn3,fn4,... ) Returns: jQuery
//Toggle among two or more function calls every other click.
//$("td").toggle(
// function () {
// $(this).addClass("selected");
// },
// function () {
// $(this).removeClass("selected");
// }
//);
////////////////////////////////////////////////////////////////////////////////////////
//Event Helpers:

//blur( ) Returns: jQuery
//Triggers the blur event of each matched element.
//$("p").blur();

//blur( fn ) Returns: jQuery
//Bind a function to the blur event of each matched element.
// $("input").blur(function () {
// $(this).next("span").css('display','inline').fadeOut(1000);
// });

//change( ) Returns: jQuery
//Triggers the change event of each matched element.
//$("p").change();

//change( fn ) Returns: jQuery
//Binds a function to the change event of each matched element.
//$("input[@type='text']").change( function() {
// // check input ($(this).val()) for validity here
//});

//click( ) Returns: jQuery
//Triggers the click event of each matched element.
//$("p").click();

//click( fn ) Returns: jQuery
//Binds a function to the click event of each matched element.
// $("p").click(function () {
// $(this).slideUp();
// });
// $("p").hover(function () {
// $(this).addClass("hilite");
// }, function () {
// $(this).removeClass("hilite");
// });

//dblclick( ) Returns: jQuery
//Triggers the dblclick event of each matched element.
//$("p").dblclick();

//dblclick( fn ) Returns: jQuery
//Binds a function to the dblclick event of each matched element.
//$("p").dblclick( function () { alert("Hello World!"); });

//error( ) Returns: jQuery
//Triggers the error event of each matched element.
//$("p").error();

//error( fn ) Returns: jQuery
//Binds a function to the error event of each matched element.
//$(window).error(function(){
// return true;
//});

//focus( ) Returns: jQuery
//Triggers the focus event of each matched element.
//$("#login").focus();

//focus( fn ) Returns: jQuery
//Binds a function to the focus event of each matched element.
//$("input[@type=text]").focus(function(){
// $(this).blur();
//});

//keydown( ) Returns: jQuery
//Triggers the keydown event of each matched element.
//$("p").keydown();

//keydown( fn ) Returns: jQuery
//Bind a function to the keydown event of each matched element.
//$(window).keydown(function(event){
// switch (event.keyCode) {
// // ...
// // different keys do different things
// // Different browsers provide different codes
// // see here for details: http://unixpapa.com/js/key.html
// // ...
// }
//});

//keypress( ) Returns: jQuery
//Triggers the keypress event of each matched element.
//$("p").keypress();

//keypress( fn ) Returns: jQuery
//Binds a function to the keypress event of each matched element.
// $("input").keypress(function (e) {
// if (e.which == 32 || (65 <= e.which && e.which <= 65 + 25)
// || (97 <= e.which && e.which <= 97 + 25)) {
// var c = String.fromCharCode(e.which);
// $("p").append($("<span/>"))
// .children(":last")
// .append(document.createTextNode(c));
// } else if (e.which == 8) {
// // backspace in IE only be on keydown
// $("p").children(":last").remove();
// }
// $("div").text(e.which);
// });

//keyup( ) Returns: jQuery
//Triggers the keyup event of each matched element.
//$("p").keyup();

//keyup( fn ) Returns: jQuery
//Bind a function to the keyup event of each matched element.
//$(document).keyup(function(event){
// if (event.keyCode == 27) {
// alert('escaped!');
// }
//});

//load( fn ) Returns: jQuery
//Binds a function to the load event of each matched element.
// $(window).load(function () {
// //run code
// });

//mousedown( fn ) Returns: jQuery
//Binds a function to the mousedown event of each matched element.
//mouseup( fn ) Returns: jQuery
//Bind a function to the mouseup event of each matched element.
// $("p").mouseup(function(){
// $(this).append('<span style="color:#F00;">Mouse up.</span>');
// }).mousedown(function(){
// $(this).append('<span style="color:#00F;">Mouse down.</span>');
// });

//mousemove( fn ) Returns: jQuery
//Bind a function to the mousemove event of each matched element.
// $("div").mousemove(function(e){
// var pageCoords = "( " + e.pageX + ", " + e.pageY + " )";
// var clientCoords = "( " + e.clientX + ", " + e.clientY + " )";
// $("span:first").text("( e.pageX, e.pageY ) - " + pageCoords);
// $("span:last").text("( e.clientX, e.clientY ) - " + clientCoords);
// });

//mouseover( fn ) Returns: jQuery
//Bind a function to the mouseover event of each matched element.
//mouseout( fn ) Returns: jQuery
//Bind a function to the mouseout event of each matched element.
// var i = 0;
// $("div.overout").mouseout(function(){
// $("p:first",this).text("mouse out");
// $("p:last",this).text(++i);
// }).mouseover(function(){
// $("p:first",this).text("mouse over");
// });
//
// var n = 0;
// $("div.enterleave").bind("mouseenter",function(){
// $("p:first",this).text("mouse enter");
// }).bind("mouseleave",function(){
// $("p:first",this).text("mouse leave");
// $("p:last",this).text(++n);
// });

//resize( fn ) Returns: jQuery
//Bind a function to the resize event of each matched element.
//$(window).resize(function(){
// alert("Stop it!");
//});

//scroll( fn ) Returns: jQuery
//Bind a function to the scroll event of each matched element.
// $("p").clone().appendTo(document.body);
// $("p").clone().appendTo(document.body);
// $("p").clone().appendTo(document.body);
// $(window).scroll(function () {
// $("span").css("display", "inline").fadeOut("slow");
// });

//select( ) Returns: jQuery
//Trigger the select event of each matched element.
//$("input").select();

//select( fn ) Returns: jQuery
//Bind a function to the select event of each matched element.
// $(document).select( function () {
// $("div").text("Something was selected").show().fadeOut(1000);
// });

//submit( ) Returns: jQuery
//Trigger the submit event of each matched element.
//$("form:first").submit();

//submit( fn ) Returns: jQuery
//Bind a function to the submit event of each matched element.
//$("form").submit( function () {
// return this.some_flag_variable;
//} );

//unload( fn ) Returns: jQuery
//Binds a function to the unload event of each matched element.
//$(window).unload( function () { alert("Bye now!"); } );
////////////////////////////////////////////////////////////////////////////////////////
});
</script>
</body>
</html>

分享到:
评论
Global site tag (gtag.js) - Google Analytics