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

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

jQuery javascript框架

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


一张图片点击鼠标放大,再点缩小基于jquery1.8.3实现,下面有个不错的示例,感兴趣的朋友可以参考下
 
<!DOCTYPE html> 
<html> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<title></title> 
<script src="jquery-1.8.3.min.js"></script> 
<script> 
var isopen = false; 
var newImg; 
var w = 200; //将图片宽度+200 
var h = 200; // 将图片高度 +200 
$(document).ready(function(){ 
$("img").bind("click", function(){ 
newImg = this; 
if (!isopen) 
{ 
isopen = true; 
$(this).width($(this).width() + w); 
$(this).height($(this).height() + h); 
moveImg(10, 10); 
} 
else 
{ 
isopen = false; 
$(this).width($(this).width() - w); 
$(this).height($(this).height() - h); 
moveImg(-10, -10); 
} 

}); 
}); 
//移位 
i = 0; 
function moveImg(left,top) 
{ 
var offset = $(newImg).offset(); 
$(newImg).offset({ top: offset.top + top, left: offset.left + left}); 
if (i == 10) 
{ 
i =0; 
return; 
} 
setTimeout("moveImg("+left+","+top+")", 10); 
i++; 
} 
</script> 
</head> 

<body> 
<div id="imgBox" style="width:100px; height:100px; background:#cccccc"> 
<img id="img1" style="width:100px;height:100px; " alt="" src="photos/image1.jpg" /> 
</div> 
</div> 
</body> 
</html> 


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

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