我使用的是jquery克隆函数,但我真的不明白会发生什么。阅读文档时指出,如果我使用克隆(True),那么所有事件处理程序都应该被复制。但这不会发生的。
所以,我试着做的是一个灯箱,在里面我复制变焦效果。这是网站。
您可以看到一张大照片与我试图克隆的缩放效果,然后如果您单击链接ver ,您将看到灯箱效果,但没有变焦。
以下是单击函数--这是我所做的函数:
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;
});
)};
)};我最后一次想让它工作的目的是在我的代码中包括缩放效果,它可以工作,
obj.bind('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');
//THIS IS THE ZOOM TRIGGER
jQuery('.imagess').epicZoom({});
return false;
});但我想知道这是否是正确的方式,为什么克隆(真)和克隆(真,真)不起作用。
发布于 2012-05-18 08:42:56
$(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);
});
});在u中,2或3‘};’是失踪,一个';‘缺少.检查一下..。
https://stackoverflow.com/questions/10646985
复制相似问题