使用AJAX动态装箱

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了使用AJAX动态装箱相关的知识,希望对你有一定的参考价值。

This is how you can create page box elements that are loaded via AJAX and can be refreshed instantly without a whole page reload.
  1. jQuery(document).ready(function($) {
  2. //event to show the box controls when the mouse hovers the box
  3. //applies to all elements with class="box"
  4. $('.box').mouseover(function(){
  5. //replace string "box" with "controls"
  6. var dyn_var = "#" + this.id.replace("box","controls");
  7. $(dyn_var).show();
  8. });
  9.  
  10. //initialize box controls
  11. $('.box .controls').hide(); //hide all box controls
  12.  
  13. //hide box when mouse exits box
  14. $('.box').mouseout(function(){
  15. $('.box .controls').hide();
  16. });
  17.  
  18. //load box content (loads after page loads)
  19. loadboxcontent('box-id1');
  20. loadboxcontent('box-id2');
  21. //etc...
  22. });

以上是关于使用AJAX动态装箱的主要内容,如果未能解决你的问题,请参考以下文章