首页 > 开发 > AJAX > 正文

jQuery+css3实现Ajax点击后动态删除功能的方法

2024-09-01 08:33:04
字体:大 中 小
来源:转载
供稿:网友

这篇文章主要介绍了jQuery+css3实现Ajax点击后动态删除功能的方法,可实现点击选区后出现选区收缩、滚动消失的效果,涉及jquery结合Ajax与数学运算实时操作页面元素的相关技巧,需要的朋友可以参考下

本文实例讲述了jQuery+css3实现Ajax点击后动态删除功能的方法。分享给大家供大家参考。具体如下:

这里使用jquery实现ajax动态删除一个方框,并带有动画缓冲效果,在google plus网站发现的特效,在此献丑模仿了一番,已基本与Google Plusp功能相同,你可在方框中加入一些内容,jquery插件选的版本是1.6.2,更高版本也是可以的。

运行效果截图如下:

jQuery+css3实现Ajax点击后动态删除功能的方法

具体代码如下:

 

 
  1. <!DOCTYPE html> 
  2. <head> 
  3. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
  4. <title>jQuery+css3实现Ajax动态点击删除功能</title> 
  5. <script type="text/javascript" src="jquery-1.6.2.min.js"></script> 
  6. <script type="text/javascript"> 
  7. jQuery.easing['jswing'] = jQuery.easing['swing']; 
  8. jQuery.extend( jQuery.easing, 
  9. { 
  10. def: 'easeOutQuad', 
  11. swing: function (x, t, b, c, d) { 
  12. return jQuery.easing[jQuery.easing.def](x, t, b, c, d); 
  13. }, 
  14. easeInQuad: function (x, t, b, c, d) { 
  15. return c*(t/=d)*t + b; 
  16. }, 
  17. easeOutQuad: function (x, t, b, c, d) { 
  18. return -c *(t/=d)*(t-2) + b; 
  19. }, 
  20. easeInOutQuad: function (x, t, b, c, d) { 
  21. if ((t/=d/2) < 1) return c/2*t*t + b; 
  22. return -c/2 * ((--t)*(t-2) - 1) + b; 
  23. }, 
  24. easeInCubic: function (x, t, b, c, d) { 
  25. return c*(t/=d)*t*t + b; 
  26. }, 
  27. easeOutCubic: function (x, t, b, c, d) { 
  28. return c*((t=t/d-1)*t*t + 1) + b; 
  29. }, 
  30. easeInOutCubic: function (x, t, b, c, d) { 
  31. if ((t/=d/2) < 1) return c/2*t*t*t + b; 
  32. return c/2*((t-=2)*t*t + 2) + b; 
  33. }, 
  34. easeInQuart: function (x, t, b, c, d) { 
  35. return c*(t/=d)*t*t*t + b; 
  36. }, 
  37. easeOutQuart: function (x, t, b, c, d) { 
  38. return -c * ((t=t/d-1)*t*t*t - 1) + b; 
  39. }, 
  40. easeInOutQuart: function (x, t, b, c, d) { 
  41. if ((t/=d/2) < 1) return c/2*t*t*t*t + b; 
  42. return -c/2 * ((t-=2)*t*t*t - 2) + b; 
  43. }, 
  44. easeInQuint: function (x, t, b, c, d) { 
  45. return c*(t/=d)*t*t*t*t + b; 
  46. }, 
  47. easeOutQuint: function (x, t, b, c, d) { 
  48. return c*((t=t/d-1)*t*t*t*t + 1) + b; 
  49. }, 
  50. easeInOutQuint: function (x, t, b, c, d) { 
  51. if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b; 
  52. return c/2*((t-=2)*t*t*t*t + 2) + b; 
  53. }, 
  54. easeInSine: function (x, t, b, c, d) { 
  55. return -c * Math.cos(t/d * (Math.PI/2)) + c + b; 
  56. }, 
  57. easeOutSine: function (x, t, b, c, d) { 
  58. return c * Math.sin(t/d * (Math.PI/2)) + b; 
  59. }, 
  60. easeInOutSine: function (x, t, b, c, d) { 
  61. return -c/2 * (Math.cos(Math.PI*t/d) - 1) + b; 
  62. }, 
  63. easeInExpo: function (x, t, b, c, d) { 
  64. return (t==0) ? b : c * Math.pow(2, 10 * (t/d - 1)) + b; 
  65. }, 
  66. easeOutExpo: function (x, t, b, c, d) { 
  67. return (t==d) ? b+c : c * (-Math.pow(2, -10 * t/d) + 1) + b; 
  68. }, 
  69. easeInOutExpo: function (x, t, b, c, d) { 
  70. if (t==0) return b; 
  71. if (t==d) return b+c; 
  72. if ((t/=d/2) < 1) return c/2 * Math.pow(2, 10 * (t - 1)) + b; 
  73. return c/2 * (-Math.pow(2, -10 * --t) + 2) + b; 
  74. }, 
  75. easeInCirc: function (x, t, b, c, d) { 
  76. return -c * (Math.sqrt(1 - (t/=d)*t) - 1) + b; 
  77. }, 
  78. easeOutCirc: function (x, t, b, c, d) { 
  79. return c * Math.sqrt(1 - (t=t/d-1)*t) + b; 
  80. }, 
  81. easeInOutCirc: function (x, t, b, c, d) { 
  82. if ((t/=d/2) < 1) return -c/2 * (Math.sqrt(1 - t*t) - 1) + b; 
  83. return c/2 * (Math.sqrt(1 - (t-=2)*t) + 1) + b; 
  84. }, 
  85. easeInElastic: function (x, t, b, c, d) { 
  86. var s=1.70158;var p=0;var a=c; 
  87. if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3; 
  88. if (a < Math.abs(c)) { a=c; var s=p/4; } 
  89. else var s = p/(2*Math.PI) * Math.asin (c/a); 
  90. return -(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b; 
  91. }, 
  92. easeOutElastic: function (x, t, b, c, d) { 
  93. var s=1.70158;var p=0;var a=c; 
  94. if (t==0) return b; if ((t/=d)==1) return b+c; if (!p) p=d*.3; 
  95. if (a < Math.abs(c)) { a=c; var s=p/4; } 
  96. else var s = p/(2*Math.PI) * Math.asin (c/a); 
  97. return a*Math.pow(2,-10*t) * Math.sin( (t*d-s)*(2*Math.PI)/p ) + c + b; 
  98. }, 
  99. easeInOutElastic: function (x, t, b, c, d) { 
  100. var s=1.70158;var p=0;var a=c; 
  101. if (t==0) return b; if ((t/=d/2)==2) return b+c; if (!p) p=d*(.3*1.5); 
  102. if (a < Math.abs(c)) { a=c; var s=p/4; } 
  103. else var s = p/(2*Math.PI) * Math.asin (c/a); 
  104. if (t < 1) return -.5*(a*Math.pow(2,10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )) + b; 
  105. return a*Math.pow(2,-10*(t-=1)) * Math.sin( (t*d-s)*(2*Math.PI)/p )*.5 + c + b; 
  106. }, 
  107. easeInBack: function (x, t, b, c, d, s) { 
  108. if (s == undefined) s = 1.70158; 
  109. return c*(t/=d)*t*((s+1)*t - s) + b; 
  110. }, 
  111. easeOutBack: function (x, t, b, c, d, s) { 
  112. if (s == undefined) s = 1.70158; 
  113. return c*((t=t/d-1)*t*((s+1)*t + s) + 1) + b; 
  114. }, 
  115. easeInOutBack: function (x, t, b, c, d, s) { 
  116. if (s == undefined) s = 1.70158; 
  117. if ((t/=d/2) < 1) return c/2*(t*t*(((s*=(1.525))+1)*t - s)) + b; 
  118. return c/2*((t-=2)*t*(((s*=(1.525))+1)*t + s) + 2) + b; 
  119. }, 
  120. easeInBounce: function (x, t, b, c, d) { 
  121. return c - jQuery.easing.easeOutBounce (x, d-t, 0, c, d) + b; 
  122. }, 
  123. easeOutBounce: function (x, t, b, c, d) { 
  124. if ((t/=d) < (1/2.75)) { 
  125. return c*(7.5625*t*t) + b; 
  126. } else if (t < (2/2.75)) { 
  127. return c*(7.5625*(t-=(1.5/2.75))*t + .75) + b; 
  128. } else if (t < (2.5/2.75)) { 
  129. return c*(7.5625*(t-=(2.25/2.75))*t + .9375) + b; 
  130. } else { 
  131. return c*(7.5625*(t-=(2.625/2.75))*t + .984375) + b; 
  132. } 
  133. }, 
  134. easeInOutBounce: function (x, t, b, c, d) { 
  135. if (t < d/2) return jQuery.easing.easeInBounce (x, t*2, 0, c, d) * .5 + b; 
  136. return jQuery.easing.easeOutBounce (x, t*2-d, 0, c, d) * .5 + c*.5 + b; 
  137. } 
  138. }); 
  139. </script> 
  140. <script type="text/javascript"> 
  141. $(document).ready(function() 
  142. { 
  143. $(".sqare").click(function() 
  144. { 
  145. $(this).animate({width:'100px',height:'100px'}, 500, 'linear', function() { 
  146. $(this).addClass('circle-label-rotate');  
  147. }).addClass('circle').html('<div class="innertext">Bye</div>').animate({"opacity":"0","margin-left":"510px"},1500,function(){ }); 
  148. $(this).slideUp({duration: 'slow',easing: 'easeOutBounce'}); 
  149. }); 
  150. }); 
  151. </script> 
  152. <style> 
  153. .circle-label-rotate {-webkit-animation-name: rotateThis;-webkit-animation-duration:2s;-webkit-animation-iteration-count:infinite;-webkit-animation-timing-function:linear;} 
  154. @-webkit-keyframes rotateThis {from {-webkit-transform:scale(1) rotate(0deg);} 
  155. to{-webkit-transform:scale(1) rotate(360deg);}} 
  156. .circle{border-radius: 50px;-moz-border-radius: 50px; -webkit-border-radius: 50px;height:100px;width:100px;background:#dedede;} 
  157. .sqare{height:100px;width:500px;border:dashed 1px #000;margin-top:10px;} 
  158. .innertext{padding:40px;} 
  159. </style> 
  160. </head> 
  161. <body> 
  162. <div> <div height="125px" align='center'>  
  163. </div></div>  
  164. <div style='width:600px;margin:0 auto'> 
  165. <h4>请点击虚线方框</h4> 
  166. <div class="sqare"> 
  167. </div> 
  168. <div class="sqare">这个方框是可以被删除的 
  169. </div> 
  170. <div class="sqare"> 
  171. </div> 
  172. <div class="sqare"> 
  173. </div> 
  174. <div class="sqare"> 
  175. </div> 
  176. </div> 
  177. </body> 
  178. </html> 

希望本文所述对大家的jquery程序设计有所帮助。

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表