jQuery .load()html内容并执行脚本 [英] jQuery .load() html content and execute script

查看:285
本文介绍了jQuery .load()html内容并执行脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的文档中具有以下功能

I have the following functions in my document

jQuery(document).ready(function() {
jQuery('body').on('click', 'a.menu', function () { 
        var target = jQuery(this).attr('href');
    jQuery('#container').load(target+' #content');
        return false;
    });

$("a.group").fancybox();

});

第一个将容器替换为菜单链接的href. 相应的子页面实际上是普通的div,但可以是完整的html(如有必要).

The first one replaces the container with the href of the menu link. The corresponding subpages are actually plain divs but could be complete html (if necessary).

第二个调用所选元素上的fancybox画廊.

The second one calls a fancybox gallery on the selected elements.

加载子页面后,如何执行此$("a.group").fancybox()?

How do i get this $("a.group").fancybox() to be executed, when the subpages are loaded?

提前很多, mart05

Many thx in advance, mart05

推荐答案

加载具有回调功能.因此,请在此执行fancybox:

Load has a callback function. so execute the fancybox in this:

jQuery('#container').load(target+' #content', function() {
              $("a.group").fancybox();
          });

这篇关于jQuery .load()html内容并执行脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆