发布于 2016-09-29 02:26:41 | 169 次阅读 | 评论: 0 | 来源: 网友投递

这里有新鲜出炉的jQuery示例,程序狗速度看过来!

jQuery javascript框架

jQuery是一个兼容多浏览器的javascript框架,核心理念是write less,do more(写得更少,做得更多)。jQuery在2006年1月由美国人John Resig在纽约的barcamp发布,吸引了来自世界各地的众多JavaScript高手加入,由Dave Methvin率领团队进行开发。


使用jquery的朋友对其中的on方法并不陌生吧,下面为大家介绍下此方法的具体使用,感兴趣的朋友可以参考下
 
<!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" xml:lang="en"> 
<head> 
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" /> 
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> 
<title></title> 
</head> 
<body> 
<input type="button" value="test" id="test"/> 
<script type="text/javascript"> 
$(function(){ 
$("#test").hello({ 
"size":1 
}); 
}); 
</script> 
<script type="text/javascript"> 
;(function($){ 
$.fn.hello = function(options){ 
var defaults = {"size":0}, 

opts = $.extend({},defaults,options), 

show = { 
play:function(options){ 
var _root = this; 
_root.autoPlay(); 
_root.eventClick(); 
}, 
autoPlay:function(){ 
console.log("auto"); 
}, 
eventClick:function(){ 
//$("#test").on("click",{show:"dd"},function(e){ 
// console.log("click :" + e.data.show); 
//}); 

$("#test").on({ 
click:function(){ 
alert("click"); 
}, 
mouseenter:function(){ 
alert("enter"); 
}, 
mouseleave:function(){ 
alert("leave"); 
} 
}); 
} 
}; 
return this.each(function(){ 
show.play(opts); 
}); 
}; 
})(jQuery); 
</script> 
</body> 
</html> 


最新网友评论  共有(0)条评论 发布评论 返回顶部

Copyright © 2007-2017 PHPERZ.COM All Rights Reserved   冀ICP备14009818号  版权声明  广告服务