jquery克隆don';即使使用真参数也不能工作

jquery克隆don';即使使用真参数也不能工作,jquery,Jquery,我正在使用jquery克隆函数,但我真的不明白会发生什么。 阅读文档时说,如果使用clone(true),则应复制所有事件处理程序。但这并没有发生 所以,我试着做的是一个灯箱,在里面我克隆了缩放效果 你可以看到一张带有我试图复制的缩放效果的大照片,然后如果你单击链接ver mas,你将看到灯箱效果,但没有缩放 这是单击功能这是我做的功能: jQuery(document).ready(function(){ var lb = '<div class="lb-cont"></

我正在使用jquery克隆函数,但我真的不明白会发生什么。 阅读文档时说,如果使用clone(true),则应复制所有事件处理程序。但这并没有发生

所以,我试着做的是一个灯箱,在里面我克隆了缩放效果

你可以看到一张带有我试图复制的缩放效果的大照片,然后如果你单击链接ver mas,你将看到灯箱效果,但没有缩放

这是单击功能这是我做的功能:

jQuery(document).ready(function(){
  var lb = '<div class="lb-cont"></div>'; 
  jQuery(lb).prependTo('body');

jQuery('.post').each(function(){

//code and vars to center the content....

obj.on('click','.vm',function(){

        var bh = jQuery('body').height();
        var contenido = jQuery('.light-cont', obj).clone(true).removeClass('hide');
        jQuery('.lb-cont').width(ww);
        jQuery('.lb-cont').height(bh);
        jQuery('.lb-cont').fadeIn('slow');
        contenido.appendTo('.lb-cont');
        return false;   

        });

)};
)};
但是我想知道这是否是正确的方法,以及为什么克隆(true)和克隆(true,true)不起作用。

$(文档)。就绪(函数(){
  $(document).ready(function () {
            var lb = '<div class="lb-cont"></div>';
            $(lb).prependTo('body');

            $('.post').each(function () {
                var obj = $(this);
                var verMas = $('.vm', obj)
                //medidas ventana
                var ww = $(window).width();
                var wh = $(window).height();

                //contenedor
                var contenedorInfo = $('.light-cont');
                //medidas del contenedor
                var lbw = contenedorInfo.width();
                var lbh = contenedorInfo.height();

                verMas.live('click', function () {
                    var bh = $('body').height();
                    var contenido = $('.light-cont', obj).clone(true, true).removeClass('hide');

                    $('.lb-cont').width(ww);
                    $('.lb-cont').height(bh);
                    $('.lb-cont').fadeIn('normal');
                    contenido.appendTo('.lb-cont');
                    var cerrar = '<div id="cerrar-cont"><div id="cerrar">X</div></div>';
                    $(cerrar).prependTo('.lb-cont .light-cont');
                    $('.imagess').epicZoom({});
                    var urlss = $('#facebook').attr('st_url');
                    stWidget.addEntry({
                        "service": "facebook",
                        "element": document.getElementById('facebook'),
                        "url": urlss,
                        "title": "sharethis",
                        "type": "large",
                        "text": "ShareThis",
                        "image": "http://www.softicons.com/download/internet-icons/social-superheros-icons-by-iconshock/png/256/sharethis_hulk.png",
                        "summary": "this is description1"
                    });
                    return false;

                });
            });

            $('#cerrar').live('click', function (event) {
                $('.lb-cont').fadeOut('normal');
            });

            function pos_obj(lbw, lbh, ww, wh) {
                contenedorInfo.css({
                    'margin-left': (ww / 2) - (lbw / 2) + 'px',
                    'margin-top': (wh / 2) - (lbh / 2) + 'px'
                });
            };

            pos_obj(lbw, lbh, ww, wh);

            $(window).resize(function () {
                ww = $(window).width();
                wh = $(window).height();
                lbw = contenedorInfo.width();
                lbh = contenedorInfo.height();
                contenedorInfo = $('.light-cont');
                $('.lb-cont').width(ww);
                pos_obj(lbw, lbh, ww, wh);
            });

        });
var lb=“”; $(磅).prependTo('body'); $('.post')。每个(函数(){ var obj=$(本); var verMas=$('.vm',obj) //麦迪达斯文塔纳酒店 var ww=$(window.width(); var wh=$(window.height(); //抗辩者 var contendOrInfo=$('.light cont'); //麦迪达斯·德尔·孔多尔酒店 var lbw=contendOrInfo.width(); var lbh=contendOrInfo.height(); verMas.live('click',函数(){ var bh=$('body').height(); var contenido=$('.light cont',obj).clone(true,true).removeClass('hide'); $('.lb cont')。宽度(ww); $('.lb cont')高度(bh); $('.lb cont').fadeIn('normal'); 内容附录('.lb cont'); var cerrar='X'; $(cerrar).prependTo('.lb cont.light cont'); $('.imagess').epicZoom({}); var urlss=$('#facebook').attr('st#u url'); stWidget.addEntry({ “服务”:“facebook”, “元素”:document.getElementById('facebook'), “url”:无url, “标题”:“共享此”, “类型”:“大型”, “文本”:“共享此文件”, “图像”:http://www.softicons.com/download/internet-icons/social-superheros-icons-by-iconshock/png/256/sharethis_hulk.png", “摘要”:“这是说明1” }); 返回false; }); }); $('cerrar').live('click',函数(事件){ $('.lb cont').fadeOut('normal'); }); 功能位置obj(lbw、lbh、ww、wh){ contendOrInfo.css({ “左边距”:(ww/2)-(lbw/2)+“px”, “页边距顶部”:(wh/2)-(lbh/2)+“px” }); }; 位置obj(lbw、lbh、ww、wh); $(窗口)。调整大小(函数(){ ww=$(window.width(); wh=$(窗口).height(); lbw=contendOrInfo.width(); lbh=contendOrInfo.height(); contendOrInfo=$('.light cont'); $('.lb cont')。宽度(ww); 位置obj(lbw、lbh、ww、wh); }); });

在u-r jquery中,两个或三个'});'缺少一个“;”她失踪了。。。检查它…

我从您尝试克隆(true,true)的最后一行中获取它。您使用的jquery版本是什么?
  $(document).ready(function () {
            var lb = '<div class="lb-cont"></div>';
            $(lb).prependTo('body');

            $('.post').each(function () {
                var obj = $(this);
                var verMas = $('.vm', obj)
                //medidas ventana
                var ww = $(window).width();
                var wh = $(window).height();

                //contenedor
                var contenedorInfo = $('.light-cont');
                //medidas del contenedor
                var lbw = contenedorInfo.width();
                var lbh = contenedorInfo.height();

                verMas.live('click', function () {
                    var bh = $('body').height();
                    var contenido = $('.light-cont', obj).clone(true, true).removeClass('hide');

                    $('.lb-cont').width(ww);
                    $('.lb-cont').height(bh);
                    $('.lb-cont').fadeIn('normal');
                    contenido.appendTo('.lb-cont');
                    var cerrar = '<div id="cerrar-cont"><div id="cerrar">X</div></div>';
                    $(cerrar).prependTo('.lb-cont .light-cont');
                    $('.imagess').epicZoom({});
                    var urlss = $('#facebook').attr('st_url');
                    stWidget.addEntry({
                        "service": "facebook",
                        "element": document.getElementById('facebook'),
                        "url": urlss,
                        "title": "sharethis",
                        "type": "large",
                        "text": "ShareThis",
                        "image": "http://www.softicons.com/download/internet-icons/social-superheros-icons-by-iconshock/png/256/sharethis_hulk.png",
                        "summary": "this is description1"
                    });
                    return false;

                });
            });

            $('#cerrar').live('click', function (event) {
                $('.lb-cont').fadeOut('normal');
            });

            function pos_obj(lbw, lbh, ww, wh) {
                contenedorInfo.css({
                    'margin-left': (ww / 2) - (lbw / 2) + 'px',
                    'margin-top': (wh / 2) - (lbh / 2) + 'px'
                });
            };

            pos_obj(lbw, lbh, ww, wh);

            $(window).resize(function () {
                ww = $(window).width();
                wh = $(window).height();
                lbw = contenedorInfo.width();
                lbh = contenedorInfo.height();
                contenedorInfo = $('.light-cont');
                $('.lb-cont').width(ww);
                pos_obj(lbw, lbh, ww, wh);
            });

        });